if_bwn.c (205141) | if_bwn.c (206358) |
---|---|
1/*- 2 * Copyright (c) 2009-2010 Weongyo Jeong <weongyo@freebsd.org> 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 --- 14 unchanged lines hidden (view full) --- 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009-2010 Weongyo Jeong <weongyo@freebsd.org> 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 --- 14 unchanged lines hidden (view full) --- 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/bwn/if_bwn.c 205141 2010-03-14 02:13:11Z weongyo $"); | 31__FBSDID("$FreeBSD: head/sys/dev/bwn/if_bwn.c 206358 2010-04-07 15:29:13Z rpaulo $"); |
32 33/* 34 * The Broadcom Wireless LAN controller driver. 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/module.h> --- 22 unchanged lines hidden (view full) --- 62#include <dev/pci/pcireg.h> 63#include <dev/siba/siba_ids.h> 64#include <dev/siba/sibareg.h> 65#include <dev/siba/sibavar.h> 66 67#include <net80211/ieee80211_var.h> 68#include <net80211/ieee80211_radiotap.h> 69#include <net80211/ieee80211_regdomain.h> | 32 33/* 34 * The Broadcom Wireless LAN controller driver. 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/module.h> --- 22 unchanged lines hidden (view full) --- 62#include <dev/pci/pcireg.h> 63#include <dev/siba/siba_ids.h> 64#include <dev/siba/sibareg.h> 65#include <dev/siba/sibavar.h> 66 67#include <net80211/ieee80211_var.h> 68#include <net80211/ieee80211_radiotap.h> 69#include <net80211/ieee80211_regdomain.h> |
70#include <net80211/ieee80211_amrr.h> | |
71#include <net80211/ieee80211_phy.h> | 70#include <net80211/ieee80211_phy.h> |
71#include <net80211/ieee80211_ratectl.h> |
|
72 73#include <dev/bwn/if_bwnreg.h> 74#include <dev/bwn/if_bwnvar.h> 75 76SYSCTL_NODE(_hw, OID_AUTO, bwn, CTLFLAG_RD, 0, "Broadcom driver parameters"); 77 78/* 79 * Tunable & sysctl variables. --- 95 unchanged lines hidden (view full) --- 175static void bwn_shm_write_4(struct bwn_mac *, uint16_t, uint16_t, 176 uint32_t); 177static void bwn_shm_ctlword(struct bwn_mac *, uint16_t, 178 uint16_t); 179static void bwn_addchannels(struct ieee80211_channel [], int, int *, 180 const struct bwn_channelinfo *, int); 181static int bwn_raw_xmit(struct ieee80211_node *, struct mbuf *, 182 const struct ieee80211_bpf_params *); | 72 73#include <dev/bwn/if_bwnreg.h> 74#include <dev/bwn/if_bwnvar.h> 75 76SYSCTL_NODE(_hw, OID_AUTO, bwn, CTLFLAG_RD, 0, "Broadcom driver parameters"); 77 78/* 79 * Tunable & sysctl variables. --- 95 unchanged lines hidden (view full) --- 175static void bwn_shm_write_4(struct bwn_mac *, uint16_t, uint16_t, 176 uint32_t); 177static void bwn_shm_ctlword(struct bwn_mac *, uint16_t, 178 uint16_t); 179static void bwn_addchannels(struct ieee80211_channel [], int, int *, 180 const struct bwn_channelinfo *, int); 181static int bwn_raw_xmit(struct ieee80211_node *, struct mbuf *, 182 const struct ieee80211_bpf_params *); |
183static void bwn_newassoc(struct ieee80211_node *, int); | |
184static void bwn_updateslot(struct ifnet *); 185static void bwn_update_promisc(struct ifnet *); 186static void bwn_wme_init(struct bwn_mac *); 187static int bwn_wme_update(struct ieee80211com *); | 183static void bwn_updateslot(struct ifnet *); 184static void bwn_update_promisc(struct ifnet *); 185static void bwn_wme_init(struct bwn_mac *); 186static int bwn_wme_update(struct ieee80211com *); |
188static struct ieee80211_node *bwn_node_alloc(struct ieee80211vap *, 189 const uint8_t [IEEE80211_ADDR_LEN]); | |
190static void bwn_wme_clear(struct bwn_softc *); 191static void bwn_wme_load(struct bwn_mac *); 192static void bwn_wme_loadparams(struct bwn_mac *, 193 const struct wmeParams *, uint16_t); | 187static void bwn_wme_clear(struct bwn_softc *); 188static void bwn_wme_load(struct bwn_mac *); 189static void bwn_wme_loadparams(struct bwn_mac *, 190 const struct wmeParams *, uint16_t); |
194static void bwn_node_cleanup(struct ieee80211_node *); | |
195static void bwn_scan_start(struct ieee80211com *); 196static void bwn_scan_end(struct ieee80211com *); 197static void bwn_set_channel(struct ieee80211com *); 198static struct ieee80211vap *bwn_vap_create(struct ieee80211com *, 199 const char [IFNAMSIZ], int, int, 200 int, const uint8_t [IEEE80211_ADDR_LEN], 201 const uint8_t [IEEE80211_ADDR_LEN]); 202static void bwn_vap_delete(struct ieee80211vap *); --- 880 unchanged lines hidden (view full) --- 1083 bwn_is_valid_ether_addr(siba_sprom_get_mac_80211a(sc->sc_dev)) ? 1084 siba_sprom_get_mac_80211a(sc->sc_dev) : 1085 siba_sprom_get_mac_80211bg(sc->sc_dev)); 1086 1087 ic->ic_headroom = sizeof(struct bwn_txhdr); 1088 1089 /* override default methods */ 1090 ic->ic_raw_xmit = bwn_raw_xmit; | 191static void bwn_scan_start(struct ieee80211com *); 192static void bwn_scan_end(struct ieee80211com *); 193static void bwn_set_channel(struct ieee80211com *); 194static struct ieee80211vap *bwn_vap_create(struct ieee80211com *, 195 const char [IFNAMSIZ], int, int, 196 int, const uint8_t [IEEE80211_ADDR_LEN], 197 const uint8_t [IEEE80211_ADDR_LEN]); 198static void bwn_vap_delete(struct ieee80211vap *); --- 880 unchanged lines hidden (view full) --- 1079 bwn_is_valid_ether_addr(siba_sprom_get_mac_80211a(sc->sc_dev)) ? 1080 siba_sprom_get_mac_80211a(sc->sc_dev) : 1081 siba_sprom_get_mac_80211bg(sc->sc_dev)); 1082 1083 ic->ic_headroom = sizeof(struct bwn_txhdr); 1084 1085 /* override default methods */ 1086 ic->ic_raw_xmit = bwn_raw_xmit; |
1091 ic->ic_newassoc = bwn_newassoc; | |
1092 ic->ic_updateslot = bwn_updateslot; 1093 ic->ic_update_promisc = bwn_update_promisc; 1094 ic->ic_wme.wme_update = bwn_wme_update; 1095 | 1087 ic->ic_updateslot = bwn_updateslot; 1088 ic->ic_update_promisc = bwn_update_promisc; 1089 ic->ic_wme.wme_update = bwn_wme_update; 1090 |
1096 ic->ic_node_alloc = bwn_node_alloc; 1097 sc->sc_node_cleanup = ic->ic_node_cleanup; 1098 ic->ic_node_cleanup = bwn_node_cleanup; 1099 | |
1100 ic->ic_scan_start = bwn_scan_start; 1101 ic->ic_scan_end = bwn_scan_end; 1102 ic->ic_set_channel = bwn_set_channel; 1103 1104 ic->ic_vap_create = bwn_vap_create; 1105 ic->ic_vap_delete = bwn_vap_delete; 1106 1107 ieee80211_radiotap_attach(ic, --- 1659 unchanged lines hidden (view full) --- 2767 ifp->if_oerrors++; 2768 } 2769 sc->sc_watchdog_timer = 5; 2770 BWN_UNLOCK(sc); 2771 return (0); 2772} 2773 2774/* | 1091 ic->ic_scan_start = bwn_scan_start; 1092 ic->ic_scan_end = bwn_scan_end; 1093 ic->ic_set_channel = bwn_set_channel; 1094 1095 ic->ic_vap_create = bwn_vap_create; 1096 ic->ic_vap_delete = bwn_vap_delete; 1097 1098 ieee80211_radiotap_attach(ic, --- 1659 unchanged lines hidden (view full) --- 2758 ifp->if_oerrors++; 2759 } 2760 sc->sc_watchdog_timer = 5; 2761 BWN_UNLOCK(sc); 2762 return (0); 2763} 2764 2765/* |
2775 * Setup driver-specific state for a newly associated node. 2776 * Note that we're called also on a re-associate, the isnew 2777 * param tells us if this is the first time or not. 2778 */ 2779static void 2780bwn_newassoc(struct ieee80211_node *ni, int isnew) 2781{ 2782 struct ieee80211vap *vap = ni->ni_vap; 2783 2784 ieee80211_amrr_node_init(&BWN_VAP(vap)->bv_amrr, 2785 &BWN_NODE(ni)->bn_amn, ni); 2786} 2787 2788/* | |
2789 * Callback from the 802.11 layer to update the slot time 2790 * based on the current setting. We use it to notify the 2791 * firmware of ERP changes and the f/w takes care of things 2792 * like slot time and preamble. 2793 */ 2794static void 2795bwn_updateslot(struct ifnet *ifp) 2796{ --- 55 unchanged lines hidden (view full) --- 2852 bwn_wme_loadparams(mac, wmep, bwn_wme_shm_offsets[i]); 2853 } 2854 bwn_mac_enable(mac); 2855 } 2856 BWN_UNLOCK(sc); 2857 return (0); 2858} 2859 | 2766 * Callback from the 802.11 layer to update the slot time 2767 * based on the current setting. We use it to notify the 2768 * firmware of ERP changes and the f/w takes care of things 2769 * like slot time and preamble. 2770 */ 2771static void 2772bwn_updateslot(struct ifnet *ifp) 2773{ --- 55 unchanged lines hidden (view full) --- 2829 bwn_wme_loadparams(mac, wmep, bwn_wme_shm_offsets[i]); 2830 } 2831 bwn_mac_enable(mac); 2832 } 2833 BWN_UNLOCK(sc); 2834 return (0); 2835} 2836 |
2860static struct ieee80211_node * 2861bwn_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) 2862{ 2863 struct ieee80211com *ic = vap->iv_ic; 2864 struct bwn_softc *sc = ic->ic_ifp->if_softc; 2865 const size_t space = sizeof(struct bwn_node); 2866 struct bwn_node *bn; 2867 2868 bn = malloc(space, M_80211_NODE, M_NOWAIT|M_ZERO); 2869 if (bn == NULL) { 2870 /* XXX stat+msg */ 2871 return (NULL); 2872 } 2873 DPRINTF(sc, BWN_DEBUG_NODE, "%s: bn %p\n", __func__, bn); 2874 return (&bn->bn_node); 2875} 2876 | |
2877static void | 2837static void |
2878bwn_node_cleanup(struct ieee80211_node *ni) 2879{ 2880 struct ieee80211com *ic = ni->ni_ic; 2881 struct bwn_softc *sc = ic->ic_ifp->if_softc; 2882 2883 sc->sc_node_cleanup(ni); 2884} 2885 2886static void | |
2887bwn_scan_start(struct ieee80211com *ic) 2888{ 2889 struct ifnet *ifp = ic->ic_ifp; 2890 struct bwn_softc *sc = ifp->if_softc; 2891 struct bwn_mac *mac; 2892 2893 BWN_LOCK(sc); 2894 mac = sc->sc_curmac; --- 118 unchanged lines hidden (view full) --- 3013 IEEE80211_ADDR_COPY(vap->iv_myaddr, mac); 3014 /* override with driver methods */ 3015 bvp->bv_newstate = vap->iv_newstate; 3016 vap->iv_newstate = bwn_newstate; 3017 3018 /* override max aid so sta's cannot assoc when we're out of sta id's */ 3019 vap->iv_max_aid = BWN_STAID_MAX; 3020 | 2838bwn_scan_start(struct ieee80211com *ic) 2839{ 2840 struct ifnet *ifp = ic->ic_ifp; 2841 struct bwn_softc *sc = ifp->if_softc; 2842 struct bwn_mac *mac; 2843 2844 BWN_LOCK(sc); 2845 mac = sc->sc_curmac; --- 118 unchanged lines hidden (view full) --- 2964 IEEE80211_ADDR_COPY(vap->iv_myaddr, mac); 2965 /* override with driver methods */ 2966 bvp->bv_newstate = vap->iv_newstate; 2967 vap->iv_newstate = bwn_newstate; 2968 2969 /* override max aid so sta's cannot assoc when we're out of sta id's */ 2970 vap->iv_max_aid = BWN_STAID_MAX; 2971 |
3021 ieee80211_amrr_init(&bvp->bv_amrr, vap, 3022 IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, 3023 IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, 3024 500 /*ms*/); | 2972 ieee80211_ratectl_init(vap); |
3025 3026 /* complete setup */ 3027 ieee80211_vap_attach(vap, ieee80211_media_change, 3028 ieee80211_media_status); 3029 return (vap); 3030} 3031 3032static void 3033bwn_vap_delete(struct ieee80211vap *vap) 3034{ 3035 struct bwn_vap *bvp = BWN_VAP(vap); 3036 | 2973 2974 /* complete setup */ 2975 ieee80211_vap_attach(vap, ieee80211_media_change, 2976 ieee80211_media_status); 2977 return (vap); 2978} 2979 2980static void 2981bwn_vap_delete(struct ieee80211vap *vap) 2982{ 2983 struct bwn_vap *bvp = BWN_VAP(vap); 2984 |
3037 ieee80211_amrr_cleanup(&bvp->bv_amrr); | 2985 ieee80211_ratectl_deinit(vap); |
3038 ieee80211_vap_detach(vap); 3039 free(bvp, M_80211_VAP); 3040} 3041 3042static void 3043bwn_init(void *arg) 3044{ 3045 struct bwn_softc *sc = arg; --- 5989 unchanged lines hidden (view full) --- 9035} 9036 9037static void 9038bwn_handle_txeof(struct bwn_mac *mac, const struct bwn_txstatus *status) 9039{ 9040 struct bwn_dma_ring *dr; 9041 struct bwn_dmadesc_generic *desc; 9042 struct bwn_dmadesc_meta *meta; | 2986 ieee80211_vap_detach(vap); 2987 free(bvp, M_80211_VAP); 2988} 2989 2990static void 2991bwn_init(void *arg) 2992{ 2993 struct bwn_softc *sc = arg; --- 5989 unchanged lines hidden (view full) --- 8983} 8984 8985static void 8986bwn_handle_txeof(struct bwn_mac *mac, const struct bwn_txstatus *status) 8987{ 8988 struct bwn_dma_ring *dr; 8989 struct bwn_dmadesc_generic *desc; 8990 struct bwn_dmadesc_meta *meta; |
9043 struct bwn_node *bn; | |
9044 struct bwn_pio_txqueue *tq; 9045 struct bwn_pio_txpkt *tp = NULL; 9046 struct bwn_softc *sc = mac->mac_sc; 9047 struct bwn_stats *stats = &mac->mac_stats; 9048 struct ieee80211_node *ni; | 8991 struct bwn_pio_txqueue *tq; 8992 struct bwn_pio_txpkt *tp = NULL; 8993 struct bwn_softc *sc = mac->mac_sc; 8994 struct bwn_stats *stats = &mac->mac_stats; 8995 struct ieee80211_node *ni; |
8996 struct ieee80211vap *vap; |
|
9049 int slot; 9050 9051 BWN_ASSERT_LOCKED(mac->mac_sc); 9052 9053 if (status->im) 9054 device_printf(sc->sc_dev, "TODO: STATUS IM\n"); 9055 if (status->ampdu) 9056 device_printf(sc->sc_dev, "TODO: STATUS AMPDU\n"); --- 12 unchanged lines hidden (view full) --- 9069 device_printf(sc->sc_dev, 9070 "failed to parse cookie\n"); 9071 return; 9072 } 9073 while (1) { 9074 dr->getdesc(dr, slot, &desc, &meta); 9075 if (meta->mt_islast) { 9076 ni = meta->mt_ni; | 8997 int slot; 8998 8999 BWN_ASSERT_LOCKED(mac->mac_sc); 9000 9001 if (status->im) 9002 device_printf(sc->sc_dev, "TODO: STATUS IM\n"); 9003 if (status->ampdu) 9004 device_printf(sc->sc_dev, "TODO: STATUS AMPDU\n"); --- 12 unchanged lines hidden (view full) --- 9017 device_printf(sc->sc_dev, 9018 "failed to parse cookie\n"); 9019 return; 9020 } 9021 while (1) { 9022 dr->getdesc(dr, slot, &desc, &meta); 9023 if (meta->mt_islast) { 9024 ni = meta->mt_ni; |
9077 bn = (struct bwn_node *)ni; 9078 ieee80211_amrr_tx_complete(&bn->bn_amn, 9079 status->ack, 0); | 9025 vap = ni->ni_vap; 9026 ieee80211_ratectl_tx_complete(vap, ni, 9027 status->ack ? 9028 IEEE80211_RATECTL_TX_SUCCESS : 9029 IEEE80211_RATECTL_TX_FAILURE, 9030 NULL, 0); |
9080 break; 9081 } 9082 slot = bwn_dma_nextslot(dr, slot); 9083 } 9084 } 9085 bwn_dma_handle_txeof(mac, status); 9086 } else { 9087 if (status->ack) { 9088 tq = bwn_pio_parse_cookie(mac, status->cookie, &tp); 9089 if (tq == NULL) { 9090 device_printf(sc->sc_dev, 9091 "failed to parse cookie\n"); 9092 return; 9093 } 9094 ni = tp->tp_ni; | 9031 break; 9032 } 9033 slot = bwn_dma_nextslot(dr, slot); 9034 } 9035 } 9036 bwn_dma_handle_txeof(mac, status); 9037 } else { 9038 if (status->ack) { 9039 tq = bwn_pio_parse_cookie(mac, status->cookie, &tp); 9040 if (tq == NULL) { 9041 device_printf(sc->sc_dev, 9042 "failed to parse cookie\n"); 9043 return; 9044 } 9045 ni = tp->tp_ni; |
9095 bn = (struct bwn_node *)ni; 9096 ieee80211_amrr_tx_complete(&bn->bn_amn, status->ack, 0); | 9046 vap = ni->ni_vap; 9047 ieee80211_ratectl_tx_complete(vap, ni, 9048 status->ack ? 9049 IEEE80211_RATECTL_TX_SUCCESS : 9050 IEEE80211_RATECTL_TX_FAILURE, 9051 NULL, 0); |
9097 } 9098 bwn_pio_handle_txeof(mac, status); 9099 } 9100 9101 bwn_phy_txpower_check(mac, 0); 9102} 9103 9104static uint8_t --- 568 unchanged lines hidden (view full) --- 9673 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; 9674 if (type != IEEE80211_FC0_TYPE_DATA || (m->m_flags & M_EAPOL)) 9675 rate = rate_fb = tp->mgmtrate; 9676 else if (ismcast) 9677 rate = rate_fb = tp->mcastrate; 9678 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) 9679 rate = rate_fb = tp->ucastrate; 9680 else { | 9052 } 9053 bwn_pio_handle_txeof(mac, status); 9054 } 9055 9056 bwn_phy_txpower_check(mac, 0); 9057} 9058 9059static uint8_t --- 568 unchanged lines hidden (view full) --- 9628 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; 9629 if (type != IEEE80211_FC0_TYPE_DATA || (m->m_flags & M_EAPOL)) 9630 rate = rate_fb = tp->mgmtrate; 9631 else if (ismcast) 9632 rate = rate_fb = tp->mcastrate; 9633 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) 9634 rate = rate_fb = tp->ucastrate; 9635 else { |
9681 rix = ieee80211_amrr_choose(ni, &BWN_NODE(ni)->bn_amn); | 9636 rix = ieee80211_ratectl_rate(ni, NULL, 0); |
9682 rate = ni->ni_txrate; 9683 9684 if (rix > 0) 9685 rate_fb = ni->ni_rates.rs_rates[rix - 1] & 9686 IEEE80211_RATE_VAL; 9687 else 9688 rate_fb = rate; 9689 } --- 4597 unchanged lines hidden --- | 9637 rate = ni->ni_txrate; 9638 9639 if (rix > 0) 9640 rate_fb = ni->ni_rates.rs_rates[rix - 1] & 9641 IEEE80211_RATE_VAL; 9642 else 9643 rate_fb = rate; 9644 } --- 4597 unchanged lines hidden --- |