if_ath.c (140428) | if_ath.c (140432) |
---|---|
1/*- 2 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 140428 2005-01-18 18:11:04Z sam $"); | 38__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 140432 2005-01-18 19:03:04Z sam $"); |
39 40/* 41 * Driver for the Atheros Wireless LAN controller. 42 * 43 * This software is derived from work of Atsushi Onoe; his contribution 44 * is greatly appreciated. 45 */ 46 --- 41 unchanged lines hidden (view full) --- 88#define LE_READ_2(p) \ 89 ((u_int16_t) \ 90 ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8))) 91#define LE_READ_4(p) \ 92 ((u_int32_t) \ 93 ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \ 94 (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))) 95 | 39 40/* 41 * Driver for the Atheros Wireless LAN controller. 42 * 43 * This software is derived from work of Atsushi Onoe; his contribution 44 * is greatly appreciated. 45 */ 46 --- 41 unchanged lines hidden (view full) --- 88#define LE_READ_2(p) \ 89 ((u_int16_t) \ 90 ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8))) 91#define LE_READ_4(p) \ 92 ((u_int32_t) \ 93 ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \ 94 (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))) 95 |
96enum { 97 ATH_LED_TX, 98 ATH_LED_RX, 99 ATH_LED_POLL, 100}; 101 |
|
96static void ath_init(void *); 97static void ath_stop_locked(struct ifnet *); 98static void ath_stop(struct ifnet *); 99static void ath_start(struct ifnet *); 100static int ath_reset(struct ifnet *); 101static int ath_media_change(struct ifnet *); 102static void ath_watchdog(struct ifnet *); 103static int ath_ioctl(struct ifnet *, u_long, caddr_t); --- 48 unchanged lines hidden (view full) --- 152static void ath_chan_change(struct ath_softc *, struct ieee80211_channel *); 153static void ath_next_scan(void *); 154static void ath_calibrate(void *); 155static int ath_newstate(struct ieee80211com *, enum ieee80211_state, int); 156static void ath_newassoc(struct ieee80211com *, 157 struct ieee80211_node *, int); 158static int ath_getchannels(struct ath_softc *, u_int cc, 159 HAL_BOOL outdoor, HAL_BOOL xchanmode); | 102static void ath_init(void *); 103static void ath_stop_locked(struct ifnet *); 104static void ath_stop(struct ifnet *); 105static void ath_start(struct ifnet *); 106static int ath_reset(struct ifnet *); 107static int ath_media_change(struct ifnet *); 108static void ath_watchdog(struct ifnet *); 109static int ath_ioctl(struct ifnet *, u_long, caddr_t); --- 48 unchanged lines hidden (view full) --- 158static void ath_chan_change(struct ath_softc *, struct ieee80211_channel *); 159static void ath_next_scan(void *); 160static void ath_calibrate(void *); 161static int ath_newstate(struct ieee80211com *, enum ieee80211_state, int); 162static void ath_newassoc(struct ieee80211com *, 163 struct ieee80211_node *, int); 164static int ath_getchannels(struct ath_softc *, u_int cc, 165 HAL_BOOL outdoor, HAL_BOOL xchanmode); |
160static void ath_update_led(struct ath_softc *); | 166static void ath_led_event(struct ath_softc *, int); |
161static void ath_update_txpow(struct ath_softc *); 162 163static int ath_rate_setup(struct ath_softc *, u_int mode); 164static void ath_setcurmode(struct ath_softc *, enum ieee80211_phymode); 165 166static void ath_sysctlattach(struct ath_softc *); 167static void ath_bpfattach(struct ath_softc *); 168static void ath_announce(struct ath_softc *); --- 41 unchanged lines hidden (view full) --- 210 ATH_DEBUG_INTR = 0x00001000, /* ISR */ 211 ATH_DEBUG_TX_PROC = 0x00002000, /* tx ISR proc */ 212 ATH_DEBUG_RX_PROC = 0x00004000, /* rx ISR proc */ 213 ATH_DEBUG_BEACON_PROC = 0x00008000, /* beacon ISR proc */ 214 ATH_DEBUG_CALIBRATE = 0x00010000, /* periodic calibration */ 215 ATH_DEBUG_KEYCACHE = 0x00020000, /* key cache management */ 216 ATH_DEBUG_STATE = 0x00040000, /* 802.11 state transitions */ 217 ATH_DEBUG_NODE = 0x00080000, /* node management */ | 167static void ath_update_txpow(struct ath_softc *); 168 169static int ath_rate_setup(struct ath_softc *, u_int mode); 170static void ath_setcurmode(struct ath_softc *, enum ieee80211_phymode); 171 172static void ath_sysctlattach(struct ath_softc *); 173static void ath_bpfattach(struct ath_softc *); 174static void ath_announce(struct ath_softc *); --- 41 unchanged lines hidden (view full) --- 216 ATH_DEBUG_INTR = 0x00001000, /* ISR */ 217 ATH_DEBUG_TX_PROC = 0x00002000, /* tx ISR proc */ 218 ATH_DEBUG_RX_PROC = 0x00004000, /* rx ISR proc */ 219 ATH_DEBUG_BEACON_PROC = 0x00008000, /* beacon ISR proc */ 220 ATH_DEBUG_CALIBRATE = 0x00010000, /* periodic calibration */ 221 ATH_DEBUG_KEYCACHE = 0x00020000, /* key cache management */ 222 ATH_DEBUG_STATE = 0x00040000, /* 802.11 state transitions */ 223 ATH_DEBUG_NODE = 0x00080000, /* node management */ |
224 ATH_DEBUG_LED = 0x00100000, /* led management */ |
|
218 ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ 219 ATH_DEBUG_ANY = 0xffffffff 220}; 221#define IFF_DUMPPKTS(sc, m) \ 222 ((sc->sc_debug & (m)) || \ 223 (sc->sc_if.if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) 224#define DPRINTF(sc, m, fmt, ...) do { \ 225 if (sc->sc_debug & (m)) \ --- 209 unchanged lines hidden (view full) --- 435 */ 436 sc->sc_setdefantenna = ath_setdefantenna; 437 sc->sc_rc = ath_rate_attach(sc); 438 if (sc->sc_rc == NULL) { 439 error = EIO; 440 goto bad2; 441 } 442 | 225 ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ 226 ATH_DEBUG_ANY = 0xffffffff 227}; 228#define IFF_DUMPPKTS(sc, m) \ 229 ((sc->sc_debug & (m)) || \ 230 (sc->sc_if.if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) 231#define DPRINTF(sc, m, fmt, ...) do { \ 232 if (sc->sc_debug & (m)) \ --- 209 unchanged lines hidden (view full) --- 442 */ 443 sc->sc_setdefantenna = ath_setdefantenna; 444 sc->sc_rc = ath_rate_attach(sc); 445 if (sc->sc_rc == NULL) { 446 error = EIO; 447 goto bad2; 448 } 449 |
450 sc->sc_blinking = 0; |
|
443 sc->sc_ledstate = 1; | 451 sc->sc_ledstate = 1; |
452 sc->sc_ledon = 0; /* low true */ 453 sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */ 454 callout_init(&sc->sc_ledtimer, CALLOUT_MPSAFE); |
|
444 /* 445 * Auto-enable soft led processing for IBM cards and for 446 * 5211 minipci cards. Users can also manually enable/disable 447 * support with a sysctl. 448 */ 449 sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID); 450 if (sc->sc_softled) { 451 ath_hal_gpioCfgOutput(ah, sc->sc_ledpin); | 455 /* 456 * Auto-enable soft led processing for IBM cards and for 457 * 5211 minipci cards. Users can also manually enable/disable 458 * support with a sysctl. 459 */ 460 sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID); 461 if (sc->sc_softled) { 462 ath_hal_gpioCfgOutput(ah, sc->sc_ledpin); |
452 ath_hal_gpioset(ah, sc->sc_ledpin, 0); | 463 ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon); |
453 } 454 455 ifp->if_softc = sc; 456 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; 457 ifp->if_start = ath_start; 458 ifp->if_watchdog = ath_watchdog; 459 ifp->if_ioctl = ath_ioctl; 460 ifp->if_init = ath_init; --- 467 unchanged lines hidden (view full) --- 928 * 929 * Note that some of this work is not possible if the 930 * hardware is gone (invalid). 931 */ 932 ieee80211_new_state(ic, IEEE80211_S_INIT, -1); 933 ifp->if_flags &= ~IFF_RUNNING; 934 ifp->if_timer = 0; 935 if (!sc->sc_invalid) { | 464 } 465 466 ifp->if_softc = sc; 467 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; 468 ifp->if_start = ath_start; 469 ifp->if_watchdog = ath_watchdog; 470 ifp->if_ioctl = ath_ioctl; 471 ifp->if_init = ath_init; --- 467 unchanged lines hidden (view full) --- 939 * 940 * Note that some of this work is not possible if the 941 * hardware is gone (invalid). 942 */ 943 ieee80211_new_state(ic, IEEE80211_S_INIT, -1); 944 ifp->if_flags &= ~IFF_RUNNING; 945 ifp->if_timer = 0; 946 if (!sc->sc_invalid) { |
936 if (sc->sc_softled) 937 ath_hal_gpioset(ah, sc->sc_ledpin, 1); | 947 if (sc->sc_softled) { 948 callout_stop(&sc->sc_ledtimer); 949 ath_hal_gpioset(ah, sc->sc_ledpin, 950 !sc->sc_ledon); 951 sc->sc_blinking = 0; 952 } |
938 ath_hal_intrset(ah, 0); 939 } 940 ath_draintxq(sc); 941 if (!sc->sc_invalid) { 942 ath_stoprecv(sc); 943 ath_hal_phydisable(ah); 944 } else 945 sc->sc_rxlink = NULL; --- 1655 unchanged lines hidden (view full) --- 2601 BUS_DMASYNC_POSTREAD); 2602 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); 2603 bf->bf_m = NULL; 2604 2605 m->m_pkthdr.rcvif = ifp; 2606 len = ds->ds_rxstat.rs_datalen; 2607 m->m_pkthdr.len = m->m_len = len; 2608 | 953 ath_hal_intrset(ah, 0); 954 } 955 ath_draintxq(sc); 956 if (!sc->sc_invalid) { 957 ath_stoprecv(sc); 958 ath_hal_phydisable(ah); 959 } else 960 sc->sc_rxlink = NULL; --- 1655 unchanged lines hidden (view full) --- 2616 BUS_DMASYNC_POSTREAD); 2617 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); 2618 bf->bf_m = NULL; 2619 2620 m->m_pkthdr.rcvif = ifp; 2621 len = ds->ds_rxstat.rs_datalen; 2622 m->m_pkthdr.len = m->m_len = len; 2623 |
2609 if (sc->sc_softled) 2610 ath_update_led(sc); | |
2611 sc->sc_stats.ast_ant_rx[ds->ds_rxstat.rs_antenna]++; 2612 2613 if (sc->sc_drvbpf) { 2614 const void *data; 2615 int hdrsize, hdrspace; 2616 u_int8_t rix; 2617 2618 /* 2619 * Discard anything shorter than an ack or cts. 2620 */ 2621 if (len < IEEE80211_ACK_LEN) { 2622 DPRINTF(sc, ATH_DEBUG_RECV, 2623 "%s: runt packet %d\n", 2624 __func__, len); 2625 sc->sc_stats.ast_rx_tooshort++; 2626 m_freem(m); 2627 goto rx_next; 2628 } 2629 rix = ds->ds_rxstat.rs_rate; | 2624 sc->sc_stats.ast_ant_rx[ds->ds_rxstat.rs_antenna]++; 2625 2626 if (sc->sc_drvbpf) { 2627 const void *data; 2628 int hdrsize, hdrspace; 2629 u_int8_t rix; 2630 2631 /* 2632 * Discard anything shorter than an ack or cts. 2633 */ 2634 if (len < IEEE80211_ACK_LEN) { 2635 DPRINTF(sc, ATH_DEBUG_RECV, 2636 "%s: runt packet %d\n", 2637 __func__, len); 2638 sc->sc_stats.ast_rx_tooshort++; 2639 m_freem(m); 2640 goto rx_next; 2641 } 2642 rix = ds->ds_rxstat.rs_rate; |
2630 sc->sc_rx_th.wr_flags = sc->sc_hwflags[rix]; 2631 sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix]; | 2643 sc->sc_rx_th.wr_flags = sc->sc_hwmap[rix].flags; 2644 sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix].ieeerate; |
2632 sc->sc_rx_th.wr_antsignal = ds->ds_rxstat.rs_rssi; 2633 sc->sc_rx_th.wr_antenna = ds->ds_rxstat.rs_antenna; 2634 /* XXX TSF */ 2635 2636 /* 2637 * Gag, deal with hardware padding of headers. This 2638 * only happens for QoS frames. We copy the 802.11 2639 * header out-of-line and supply it separately, then --- 31 unchanged lines hidden (view full) --- 2671 __func__, len); 2672 sc->sc_stats.ast_rx_tooshort++; 2673 m_freem(m); 2674 goto rx_next; 2675 } 2676 2677 if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) { 2678 ieee80211_dump_pkt(mtod(m, caddr_t), len, | 2645 sc->sc_rx_th.wr_antsignal = ds->ds_rxstat.rs_rssi; 2646 sc->sc_rx_th.wr_antenna = ds->ds_rxstat.rs_antenna; 2647 /* XXX TSF */ 2648 2649 /* 2650 * Gag, deal with hardware padding of headers. This 2651 * only happens for QoS frames. We copy the 802.11 2652 * header out-of-line and supply it separately, then --- 31 unchanged lines hidden (view full) --- 2684 __func__, len); 2685 sc->sc_stats.ast_rx_tooshort++; 2686 m_freem(m); 2687 goto rx_next; 2688 } 2689 2690 if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) { 2691 ieee80211_dump_pkt(mtod(m, caddr_t), len, |
2679 sc->sc_hwmap[ds->ds_rxstat.rs_rate], | 2692 sc->sc_hwmap[ds->ds_rxstat.rs_rate].ieeerate, |
2680 ds->ds_rxstat.rs_rssi); 2681 } 2682 2683 m_adj(m, -IEEE80211_CRC_LEN); 2684 2685 /* 2686 * Locate the node for sender, track state, and then 2687 * pass the (referenced) node up to the 802.11 layer --- 22 unchanged lines hidden (view full) --- 2710 } 2711 2712 /* 2713 * Send frame up for processing. 2714 */ 2715 ieee80211_input(ic, m, ni, 2716 ds->ds_rxstat.rs_rssi, ds->ds_rxstat.rs_tstamp); 2717 | 2693 ds->ds_rxstat.rs_rssi); 2694 } 2695 2696 m_adj(m, -IEEE80211_CRC_LEN); 2697 2698 /* 2699 * Locate the node for sender, track state, and then 2700 * pass the (referenced) node up to the 802.11 layer --- 22 unchanged lines hidden (view full) --- 2723 } 2724 2725 /* 2726 * Send frame up for processing. 2727 */ 2728 ieee80211_input(ic, m, ni, 2729 ds->ds_rxstat.rs_rssi, ds->ds_rxstat.rs_tstamp); 2730 |
2731 if (sc->sc_softled) { 2732 /* 2733 * Blink for any data frame. Otherwise do a 2734 * heartbeat-style blink when idle. The latter 2735 * is mainly for station mode where we depend on 2736 * periodic beacon frames to trigger the poll event. 2737 */ 2738 if (sc->sc_ipackets != ifp->if_ipackets) { 2739 sc->sc_ipackets = ifp->if_ipackets; 2740 sc->sc_rxrate = ds->ds_rxstat.rs_rate; 2741 ath_led_event(sc, ATH_LED_RX); 2742 } else if (ticks - sc->sc_ledevent >= sc->sc_ledidle) 2743 ath_led_event(sc, ATH_LED_POLL); 2744 } 2745 |
|
2718 /* 2719 * Reclaim node reference. 2720 */ 2721 ieee80211_free_node(ni); 2722rx_next: 2723 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); 2724 } while (ath_rxbuf_init(sc, bf) == 0); 2725 --- 363 unchanged lines hidden (view full) --- 3089 break; 3090 case IEEE80211_FC0_TYPE_DATA: 3091 atype = HAL_PKT_TYPE_NORMAL; /* default */ 3092 /* 3093 * Data frames; consult the rate control module. 3094 */ 3095 ath_rate_findrate(sc, an, shortPreamble, pktlen, 3096 &rix, &try0, &txrate); | 2746 /* 2747 * Reclaim node reference. 2748 */ 2749 ieee80211_free_node(ni); 2750rx_next: 2751 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); 2752 } while (ath_rxbuf_init(sc, bf) == 0); 2753 --- 363 unchanged lines hidden (view full) --- 3117 break; 3118 case IEEE80211_FC0_TYPE_DATA: 3119 atype = HAL_PKT_TYPE_NORMAL; /* default */ 3120 /* 3121 * Data frames; consult the rate control module. 3122 */ 3123 ath_rate_findrate(sc, an, shortPreamble, pktlen, 3124 &rix, &try0, &txrate); |
3125 sc->sc_txrate = txrate; /* for LED blinking */ |
|
3097 /* 3098 * Default all non-QoS traffic to the background queue. 3099 */ 3100 if (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_QOS) { 3101 u_int pri = M_WME_GETAC(m0); 3102 txq = sc->sc_ac2q[pri]; 3103 if (ic->ic_wme.wme_wmeChanParams.cap_wmeParams[pri].wmep_noackPolicy) 3104 flags |= HAL_TXDESC_NOACK; --- 106 unchanged lines hidden (view full) --- 3211 * Must disable multi-rate retry when using RTS/CTS. 3212 */ 3213 try0 = ATH_TXMAXTRY; 3214 } else 3215 ctsrate = 0; 3216 3217 if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT)) 3218 ieee80211_dump_pkt(mtod(m0, caddr_t), m0->m_len, | 3126 /* 3127 * Default all non-QoS traffic to the background queue. 3128 */ 3129 if (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_QOS) { 3130 u_int pri = M_WME_GETAC(m0); 3131 txq = sc->sc_ac2q[pri]; 3132 if (ic->ic_wme.wme_wmeChanParams.cap_wmeParams[pri].wmep_noackPolicy) 3133 flags |= HAL_TXDESC_NOACK; --- 106 unchanged lines hidden (view full) --- 3240 * Must disable multi-rate retry when using RTS/CTS. 3241 */ 3242 try0 = ATH_TXMAXTRY; 3243 } else 3244 ctsrate = 0; 3245 3246 if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT)) 3247 ieee80211_dump_pkt(mtod(m0, caddr_t), m0->m_len, |
3219 sc->sc_hwmap[txrate], -1); | 3248 sc->sc_hwmap[txrate].ieeerate, -1); |
3220 3221 if (ic->ic_rawbpf) 3222 bpf_mtap(ic->ic_rawbpf, m0); 3223 if (sc->sc_drvbpf) { | 3249 3250 if (ic->ic_rawbpf) 3251 bpf_mtap(ic->ic_rawbpf, m0); 3252 if (sc->sc_drvbpf) { |
3224 sc->sc_tx_th.wt_flags = sc->sc_hwflags[txrate]; | 3253 sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].flags; |
3225 if (iswep) 3226 sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP; | 3254 if (iswep) 3255 sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP; |
3227 sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate]; | 3256 sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate; |
3228 sc->sc_tx_th.wt_txpower = ni->ni_txpower; 3229 sc->sc_tx_th.wt_antenna = sc->sc_txantenna; 3230 3231 bpf_mtap2(sc->sc_drvbpf, 3232 &sc->sc_tx_th, sc->sc_tx_th_len, m0); 3233 } 3234 3235 /* --- 98 unchanged lines hidden (view full) --- 3334 DPRINTF(sc, ATH_DEBUG_XMIT, 3335 "%s: link[%u](%p)=%p (%p) depth %d\n", __func__, 3336 txq->axq_qnum, txq->axq_link, 3337 (caddr_t)bf->bf_daddr, bf->bf_desc, txq->axq_depth); 3338 } 3339 txq->axq_link = &bf->bf_desc[bf->bf_nseg - 1].ds_link; 3340 ATH_TXQ_UNLOCK(txq); 3341 | 3257 sc->sc_tx_th.wt_txpower = ni->ni_txpower; 3258 sc->sc_tx_th.wt_antenna = sc->sc_txantenna; 3259 3260 bpf_mtap2(sc->sc_drvbpf, 3261 &sc->sc_tx_th, sc->sc_tx_th_len, m0); 3262 } 3263 3264 /* --- 98 unchanged lines hidden (view full) --- 3363 DPRINTF(sc, ATH_DEBUG_XMIT, 3364 "%s: link[%u](%p)=%p (%p) depth %d\n", __func__, 3365 txq->axq_qnum, txq->axq_link, 3366 (caddr_t)bf->bf_daddr, bf->bf_desc, txq->axq_depth); 3367 } 3368 txq->axq_link = &bf->bf_desc[bf->bf_nseg - 1].ds_link; 3369 ATH_TXQ_UNLOCK(txq); 3370 |
3342 if (sc->sc_softled) 3343 ath_update_led(sc); 3344 | |
3345 /* 3346 * The CAB queue is started from the SWBA handler since 3347 * frames only go out on DTIM and to avoid possible races. 3348 */ 3349 if (txq != sc->sc_cabq) 3350 ath_hal_txstart(ah, txq->axq_qnum); 3351 return 0; 3352} --- 111 unchanged lines hidden (view full) --- 3464 struct ath_softc *sc = arg; 3465 struct ifnet *ifp = &sc->sc_if; 3466 3467 ath_tx_processq(sc, &sc->sc_txq[0]); 3468 ath_tx_processq(sc, sc->sc_cabq); 3469 ifp->if_flags &= ~IFF_OACTIVE; 3470 sc->sc_tx_timer = 0; 3471 | 3371 /* 3372 * The CAB queue is started from the SWBA handler since 3373 * frames only go out on DTIM and to avoid possible races. 3374 */ 3375 if (txq != sc->sc_cabq) 3376 ath_hal_txstart(ah, txq->axq_qnum); 3377 return 0; 3378} --- 111 unchanged lines hidden (view full) --- 3490 struct ath_softc *sc = arg; 3491 struct ifnet *ifp = &sc->sc_if; 3492 3493 ath_tx_processq(sc, &sc->sc_txq[0]); 3494 ath_tx_processq(sc, sc->sc_cabq); 3495 ifp->if_flags &= ~IFF_OACTIVE; 3496 sc->sc_tx_timer = 0; 3497 |
3498 if (sc->sc_softled) 3499 ath_led_event(sc, ATH_LED_TX); 3500 |
|
3472 ath_start(ifp); 3473} 3474 3475/* 3476 * Deferred processing of transmit interrupt; special-cased 3477 * for four hardware queues, 0-3 (e.g. 5212 w/ WME support). 3478 */ 3479static void --- 9 unchanged lines hidden (view full) --- 3489 ath_tx_processq(sc, &sc->sc_txq[1]); 3490 ath_tx_processq(sc, &sc->sc_txq[2]); 3491 ath_tx_processq(sc, &sc->sc_txq[3]); 3492 ath_tx_processq(sc, sc->sc_cabq); 3493 3494 ifp->if_flags &= ~IFF_OACTIVE; 3495 sc->sc_tx_timer = 0; 3496 | 3501 ath_start(ifp); 3502} 3503 3504/* 3505 * Deferred processing of transmit interrupt; special-cased 3506 * for four hardware queues, 0-3 (e.g. 5212 w/ WME support). 3507 */ 3508static void --- 9 unchanged lines hidden (view full) --- 3518 ath_tx_processq(sc, &sc->sc_txq[1]); 3519 ath_tx_processq(sc, &sc->sc_txq[2]); 3520 ath_tx_processq(sc, &sc->sc_txq[3]); 3521 ath_tx_processq(sc, sc->sc_cabq); 3522 3523 ifp->if_flags &= ~IFF_OACTIVE; 3524 sc->sc_tx_timer = 0; 3525 |
3526 if (sc->sc_softled) 3527 ath_led_event(sc, ATH_LED_TX); 3528 |
|
3497 ath_start(ifp); 3498} 3499 3500/* 3501 * Deferred processing of transmit interrupt. 3502 */ 3503static void 3504ath_tx_proc(void *arg, int npending) --- 8 unchanged lines hidden (view full) --- 3513 /* XXX faster to read ISR_S0_S and ISR_S1_S to determine q's? */ 3514 for (i = 0; i < HAL_NUM_TX_QUEUES; i++) 3515 if (ATH_TXQ_SETUP(sc, i)) 3516 ath_tx_processq(sc, &sc->sc_txq[i]); 3517 3518 ifp->if_flags &= ~IFF_OACTIVE; 3519 sc->sc_tx_timer = 0; 3520 | 3529 ath_start(ifp); 3530} 3531 3532/* 3533 * Deferred processing of transmit interrupt. 3534 */ 3535static void 3536ath_tx_proc(void *arg, int npending) --- 8 unchanged lines hidden (view full) --- 3545 /* XXX faster to read ISR_S0_S and ISR_S1_S to determine q's? */ 3546 for (i = 0; i < HAL_NUM_TX_QUEUES; i++) 3547 if (ATH_TXQ_SETUP(sc, i)) 3548 ath_tx_processq(sc, &sc->sc_txq[i]); 3549 3550 ifp->if_flags &= ~IFF_OACTIVE; 3551 sc->sc_tx_timer = 0; 3552 |
3553 if (sc->sc_softled) 3554 ath_led_event(sc, ATH_LED_TX); 3555 |
|
3521 ath_start(ifp); 3522} 3523 3524static void 3525ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq) 3526{ 3527 struct ath_hal *ah = sc->sc_ah; 3528 struct ieee80211_node *ni; --- 467 unchanged lines hidden (view full) --- 3996 ic->ic_channels[ix].ic_flags |= c->channelFlags; 3997 } 3998 } 3999 free(chans, M_TEMP); 4000 return 0; 4001} 4002 4003static void | 3556 ath_start(ifp); 3557} 3558 3559static void 3560ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq) 3561{ 3562 struct ath_hal *ah = sc->sc_ah; 3563 struct ieee80211_node *ni; --- 467 unchanged lines hidden (view full) --- 4031 ic->ic_channels[ix].ic_flags |= c->channelFlags; 4032 } 4033 } 4034 free(chans, M_TEMP); 4035 return 0; 4036} 4037 4038static void |
4004ath_update_led(struct ath_softc *sc) | 4039ath_led_done(void *arg) |
4005{ | 4040{ |
4006 struct ieee80211com *ic = &sc->sc_ic; 4007 struct ath_hal *ah = sc->sc_ah; 4008 u_int32_t threshold; | 4041 struct ath_softc *sc = arg; |
4009 | 4042 |
4010 /* 4011 * When not associated, flash LED on for 5s, off for 200ms. 4012 * XXX this assumes 100ms beacon interval. 4013 */ 4014 if (ic->ic_state != IEEE80211_S_RUN) { 4015 threshold = 2 + sc->sc_ledstate * 48; 4016 } else { 4017 threshold = 2 + sc->sc_ledstate * 18; | 4043 sc->sc_blinking = 0; 4044} 4045 4046/* 4047 * Turn the LED off: flip the pin and then set a timer so no 4048 * update will happen for the specified duration. 4049 */ 4050static void 4051ath_led_off(void *arg) 4052{ 4053 struct ath_softc *sc = arg; 4054 4055 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); 4056 callout_reset(&sc->sc_ledtimer, sc->sc_ledoff, ath_led_done, sc); 4057} 4058 4059/* 4060 * Blink the LED according to the specified on/off times. 4061 */ 4062static void 4063ath_led_blink(struct ath_softc *sc, int on, int off) 4064{ 4065 DPRINTF(sc, ATH_DEBUG_LED, "%s: on %u off %u\n", __func__, on, off); 4066 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, sc->sc_ledon); 4067 sc->sc_blinking = 1; 4068 sc->sc_ledoff = off; 4069 callout_reset(&sc->sc_ledtimer, on, ath_led_off, sc); 4070} 4071 4072static void 4073ath_led_event(struct ath_softc *sc, int event) 4074{ 4075 4076 sc->sc_ledevent = ticks; /* time of last event */ 4077 if (sc->sc_blinking) /* don't interrupt active blink */ 4078 return; 4079 switch (event) { 4080 case ATH_LED_POLL: 4081 ath_led_blink(sc, sc->sc_hwmap[0].ledon, 4082 sc->sc_hwmap[0].ledoff); 4083 break; 4084 case ATH_LED_TX: 4085 ath_led_blink(sc, sc->sc_hwmap[sc->sc_txrate].ledon, 4086 sc->sc_hwmap[sc->sc_txrate].ledoff); 4087 break; 4088 case ATH_LED_RX: 4089 ath_led_blink(sc, sc->sc_hwmap[sc->sc_rxrate].ledon, 4090 sc->sc_hwmap[sc->sc_rxrate].ledoff); 4091 break; |
4018 } | 4092 } |
4019 if (ic->ic_stats.is_rx_beacon - sc->sc_beacons >= threshold) { 4020 ath_hal_gpioCfgOutput(ah, sc->sc_ledpin); 4021 ath_hal_gpioset(ah, sc->sc_ledpin, sc->sc_ledstate); 4022 sc->sc_ledstate ^= 1; 4023 sc->sc_beacons = ic->ic_stats.is_rx_beacon; 4024 } | |
4025} 4026 4027static void 4028ath_update_txpow(struct ath_softc *sc) 4029{ 4030 struct ieee80211com *ic = &sc->sc_ic; 4031 struct ath_hal *ah = sc->sc_ah; 4032 u_int32_t txpow; --- 56 unchanged lines hidden (view full) --- 4089 rs->rs_rates[i] = rt->info[i].dot11Rate; 4090 rs->rs_nrates = maxrates; 4091 return 1; 4092} 4093 4094static void 4095ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) 4096{ | 4093} 4094 4095static void 4096ath_update_txpow(struct ath_softc *sc) 4097{ 4098 struct ieee80211com *ic = &sc->sc_ic; 4099 struct ath_hal *ah = sc->sc_ah; 4100 u_int32_t txpow; --- 56 unchanged lines hidden (view full) --- 4157 rs->rs_rates[i] = rt->info[i].dot11Rate; 4158 rs->rs_nrates = maxrates; 4159 return 1; 4160} 4161 4162static void 4163ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) 4164{ |
4165#define N(a) (sizeof(a)/sizeof(a[0])) 4166 /* NB: on/off times from the Atheros NDIS driver, w/ permission */ 4167 static const struct { 4168 u_int rate; /* tx/rx 802.11 rate */ 4169 u_int16_t timeOn; /* LED on time (ms) */ 4170 u_int16_t timeOff; /* LED off time (ms) */ 4171 } blinkrates[] = { 4172 { 108, 40, 10 }, 4173 { 96, 44, 11 }, 4174 { 72, 50, 13 }, 4175 { 48, 57, 14 }, 4176 { 36, 67, 16 }, 4177 { 24, 80, 20 }, 4178 { 22, 100, 25 }, 4179 { 18, 133, 34 }, 4180 { 12, 160, 40 }, 4181 { 10, 200, 50 }, 4182 { 6, 240, 58 }, 4183 { 4, 267, 66 }, 4184 { 2, 400, 100 }, 4185 { 0, 500, 130 }, 4186 }; |
|
4097 const HAL_RATE_TABLE *rt; | 4187 const HAL_RATE_TABLE *rt; |
4098 int i; | 4188 int i, j; |
4099 4100 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); 4101 rt = sc->sc_rates[mode]; 4102 KASSERT(rt != NULL, ("no h/w rate set for phy mode %u", mode)); 4103 for (i = 0; i < rt->rateCount; i++) 4104 sc->sc_rixmap[rt->info[i].dot11Rate & IEEE80211_RATE_VAL] = i; 4105 memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); | 4189 4190 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); 4191 rt = sc->sc_rates[mode]; 4192 KASSERT(rt != NULL, ("no h/w rate set for phy mode %u", mode)); 4193 for (i = 0; i < rt->rateCount; i++) 4194 sc->sc_rixmap[rt->info[i].dot11Rate & IEEE80211_RATE_VAL] = i; 4195 memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); |
4106 memset(sc->sc_hwflags, 0, sizeof(sc->sc_hwflags)); | |
4107 for (i = 0; i < 32; i++) { 4108 u_int8_t ix = rt->rateCodeToIndex[i]; | 4196 for (i = 0; i < 32; i++) { 4197 u_int8_t ix = rt->rateCodeToIndex[i]; |
4109 if (ix == 0xff) | 4198 if (ix == 0xff) { 4199 sc->sc_hwmap[i].ledon = (500 * hz) / 1000; 4200 sc->sc_hwmap[i].ledoff = (130 * hz) / 1000; |
4110 continue; | 4201 continue; |
4111 sc->sc_hwmap[i] = rt->info[ix].dot11Rate & IEEE80211_RATE_VAL; | 4202 } 4203 sc->sc_hwmap[i].ieeerate = 4204 rt->info[ix].dot11Rate & IEEE80211_RATE_VAL; |
4112 if (rt->info[ix].shortPreamble || 4113 rt->info[ix].phy == IEEE80211_T_OFDM) | 4205 if (rt->info[ix].shortPreamble || 4206 rt->info[ix].phy == IEEE80211_T_OFDM) |
4114 sc->sc_hwflags[i] |= IEEE80211_RADIOTAP_F_SHORTPRE; | 4207 sc->sc_hwmap[i].flags |= IEEE80211_RADIOTAP_F_SHORTPRE; 4208 /* setup blink rate table to avoid per-packet lookup */ 4209 for (j = 0; j < N(blinkrates)-1; j++) 4210 if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate) 4211 break; 4212 /* NB: this uses the last entry if the rate isn't found */ 4213 /* XXX beware of overlow */ 4214 sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000; 4215 sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000; |
4115 } 4116 sc->sc_currates = rt; 4117 sc->sc_curmode = mode; 4118 /* 4119 * All protection frames are transmited at 2Mb/s for 4120 * 11g, otherwise at 1Mb/s. 4121 * XXX select protection rate index from rate table. 4122 */ 4123 sc->sc_protrix = (mode == IEEE80211_MODE_11G ? 1 : 0); 4124 /* NB: caller is responsible for reseting rate control state */ | 4216 } 4217 sc->sc_currates = rt; 4218 sc->sc_curmode = mode; 4219 /* 4220 * All protection frames are transmited at 2Mb/s for 4221 * 11g, otherwise at 1Mb/s. 4222 * XXX select protection rate index from rate table. 4223 */ 4224 sc->sc_protrix = (mode == IEEE80211_MODE_11G ? 1 : 0); 4225 /* NB: caller is responsible for reseting rate control state */ |
4226#undef N |
|
4125} 4126 4127#ifdef AR_DEBUG 4128static void 4129ath_printrxbuf(struct ath_buf *bf, int done) 4130{ 4131 struct ath_desc *ds; 4132 int i; --- 230 unchanged lines hidden (view full) --- 4363{ 4364 struct ath_softc *sc = arg1; 4365 int softled = sc->sc_softled; 4366 int error; 4367 4368 error = sysctl_handle_int(oidp, &softled, 0, req); 4369 if (error || !req->newptr) 4370 return error; | 4227} 4228 4229#ifdef AR_DEBUG 4230static void 4231ath_printrxbuf(struct ath_buf *bf, int done) 4232{ 4233 struct ath_desc *ds; 4234 int i; --- 230 unchanged lines hidden (view full) --- 4465{ 4466 struct ath_softc *sc = arg1; 4467 int softled = sc->sc_softled; 4468 int error; 4469 4470 error = sysctl_handle_int(oidp, &softled, 0, req); 4471 if (error || !req->newptr) 4472 return error; |
4371 if (softled > 1) 4372 softled = 1; | 4473 softled = (softled != 0); |
4373 if (softled != sc->sc_softled) { | 4474 if (softled != sc->sc_softled) { |
4374 if (softled) | 4475 if (softled) { 4476 /* NB: handle any sc_ledpin change */ |
4375 ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin); | 4477 ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin); |
4376 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !softled); | 4478 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, 4479 !sc->sc_ledon); 4480 } |
4377 sc->sc_softled = softled; 4378 } 4379 return 0; 4380} 4381 4382static int 4383ath_sysctl_rxantenna(SYSCTL_HANDLER_ARGS) 4384{ --- 94 unchanged lines hidden (view full) --- 4479 ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)"); 4480 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4481 "softled", CTLTYPE_INT | CTLFLAG_RW, sc, 0, 4482 ath_sysctl_softled, "I", "enable/disable software LED support"); 4483 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4484 "ledpin", CTLFLAG_RW, &sc->sc_ledpin, 0, 4485 "GPIO pin connected to LED"); 4486 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, | 4481 sc->sc_softled = softled; 4482 } 4483 return 0; 4484} 4485 4486static int 4487ath_sysctl_rxantenna(SYSCTL_HANDLER_ARGS) 4488{ --- 94 unchanged lines hidden (view full) --- 4583 ath_sysctl_ctstimeout, "I", "802.11 CTS timeout (us)"); 4584 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4585 "softled", CTLTYPE_INT | CTLFLAG_RW, sc, 0, 4586 ath_sysctl_softled, "I", "enable/disable software LED support"); 4587 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4588 "ledpin", CTLFLAG_RW, &sc->sc_ledpin, 0, 4589 "GPIO pin connected to LED"); 4590 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, |
4591 "ledon", CTLFLAG_RW, &sc->sc_ledon, 0, 4592 "setting to turn LED on"); 4593 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4594 "ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0, 4595 "idle time for inactivity LED (ticks)"); 4596 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, |
|
4487 "txantenna", CTLFLAG_RW, &sc->sc_txantenna, 0, 4488 "tx antenna (0=auto)"); 4489 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4490 "rxantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0, 4491 ath_sysctl_rxantenna, "I", "default/rx antenna"); 4492 if (sc->sc_hasdiversity) 4493 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4494 "diversity", CTLTYPE_INT | CTLFLAG_RW, sc, 0, --- 91 unchanged lines hidden --- | 4597 "txantenna", CTLFLAG_RW, &sc->sc_txantenna, 0, 4598 "tx antenna (0=auto)"); 4599 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4600 "rxantenna", CTLTYPE_INT | CTLFLAG_RW, sc, 0, 4601 ath_sysctl_rxantenna, "I", "default/rx antenna"); 4602 if (sc->sc_hasdiversity) 4603 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 4604 "diversity", CTLTYPE_INT | CTLFLAG_RW, sc, 0, --- 91 unchanged lines hidden --- |