From owner-p4-projects@FreeBSD.ORG Mon Jan 1 06:34:11 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E72F016A416; Mon, 1 Jan 2007 06:34:10 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB0DB16A407 for ; Mon, 1 Jan 2007 06:34:10 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 9A4ED13C448 for ; Mon, 1 Jan 2007 06:34:10 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l016YAmw096355 for ; Mon, 1 Jan 2007 06:34:10 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l016YA1J096352 for perforce@freebsd.org; Mon, 1 Jan 2007 06:34:10 GMT (envelope-from kmacy@freebsd.org) Date: Mon, 1 Jan 2007 06:34:10 GMT Message-Id: <200701010634.l016YA1J096352@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 112394 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jan 2007 06:34:11 -0000 http://perforce.freebsd.org/chv.cgi?CH=112394 Change 112394 by kmacy@kmacy_serendipity:sam_wifi on 2007/01/01 06:33:49 myriad cleanups to get ral up and going under sam_wifi convert channels to new packed format - don't overlap b/g add scan_start, scan_end, and set_channel copy over power management from ath TODO: locking needs some serious re-working to interact happily with FreeBSD's network stack - avoid running ral under SMP Affected files ... .. //depot/projects/wifi/sys/dev/ral/rt2560.c#4 edit Differences ... ==== //depot/projects/wifi/sys/dev/ral/rt2560.c#4 (text) ==== @@ -64,6 +64,7 @@ #include #include + #ifdef RAL_DEBUG #define DPRINTF(x) do { if (ral_debug > 0) printf x; } while (0) #define DPRINTFN(n, x) do { if (ral_debug >= (n)) printf x; } while (0) @@ -104,6 +105,9 @@ static void rt2560_wakeup_expire(struct rt2560_softc *); static uint8_t rt2560_rxrate(struct rt2560_rx_desc *); static int rt2560_ack_rate(struct ieee80211com *, int); +static void rt2560_scan_start(struct ieee80211com *); +static void rt2560_scan_end(struct ieee80211com *); +static void rt2560_set_channel(struct ieee80211com *); static uint16_t rt2560_txtime(int, int, uint32_t); static uint8_t rt2560_plcp_signal(int); static void rt2560_setup_tx_desc(struct rt2560_softc *, @@ -136,7 +140,7 @@ static void rt2560_update_slot(struct ifnet *); static void rt2560_set_basicrates(struct rt2560_softc *); static void rt2560_update_led(struct rt2560_softc *, int, int); -static void rt2560_set_bssid(struct rt2560_softc *, uint8_t *); +static void rt2560_set_bssid(struct rt2560_softc *, const uint8_t *); static void rt2560_set_macaddr(struct rt2560_softc *, uint8_t *); static void rt2560_get_macaddr(struct rt2560_softc *, uint8_t *); static void rt2560_update_promisc(struct rt2560_softc *); @@ -198,7 +202,7 @@ struct rt2560_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp; - int error, i; + int error, i, j; sc->sc_dev = dev; @@ -284,42 +288,54 @@ IEEE80211_C_SHSLOT | /* short slot time supported */ IEEE80211_C_WPA; /* 802.11i */ + /* set supported .11b and .11g channels (1 through 14) */ + for (j = 0, i = 1; i <= 14; i++) { + ic->ic_channels[j].ic_freq = + ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ); + ic->ic_channels[j].ic_flags = IEEE80211_CHAN_B; + ic->ic_channels[j].ic_ieee = i; + j++; + + ic->ic_channels[j].ic_freq = + ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ); + ic->ic_channels[j].ic_flags = IEEE80211_CHAN_G; + ic->ic_channels[j].ic_ieee = i; + j++; + } + if (sc->rf_rev == RT2560_RF_5222) { /* set supported .11a rates */ ic->ic_sup_rates[IEEE80211_MODE_11A] = rt2560_rateset_11a; /* set supported .11a channels */ - for (i = 36; i <= 64; i += 4) { - ic->ic_channels[i].ic_freq = + for (i = 36; i <= 64; i += 4, j++) { + ic->ic_channels[j].ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); - ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; + ic->ic_channels[j].ic_flags = IEEE80211_CHAN_A; + ic->ic_channels[j].ic_ieee = i; } - for (i = 100; i <= 140; i += 4) { - ic->ic_channels[i].ic_freq = + for (i = 100; i <= 140; i += 4, j++) { + ic->ic_channels[j].ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); - ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; + ic->ic_channels[j].ic_flags = IEEE80211_CHAN_A; + ic->ic_channels[j].ic_ieee = i; } - for (i = 149; i <= 161; i += 4) { - ic->ic_channels[i].ic_freq = + for (i = 149; i <= 161; i += 4, j++) { + ic->ic_channels[j].ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); - ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; + ic->ic_channels[j].ic_flags = IEEE80211_CHAN_A; + ic->ic_channels[j].ic_ieee = i; } } /* set supported .11b and .11g rates */ ic->ic_sup_rates[IEEE80211_MODE_11B] = rt2560_rateset_11b; ic->ic_sup_rates[IEEE80211_MODE_11G] = rt2560_rateset_11g; - - /* set supported .11b and .11g channels (1 through 14) */ - for (i = 1; i <= 14; i++) { - ic->ic_channels[i].ic_freq = - ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ); - ic->ic_channels[i].ic_flags = - IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | - IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; - } - + ic->ic_nchans = j; ieee80211_ifattach(ic); + ic->ic_scan_start = rt2560_scan_start; + ic->ic_scan_end = rt2560_scan_end; + ic->ic_set_channel = rt2560_set_channel; ic->ic_node_alloc = rt2560_node_alloc; ic->ic_updateslot = rt2560_update_slot; ic->ic_reset = rt2560_reset; @@ -749,14 +765,13 @@ int error; error = ieee80211_media_change(ifp); - if (error != ENETRESET) - return error; - if ((ifp->if_flags & IFF_UP) && - (ifp->if_drv_flags & IFF_DRV_RUNNING)) - rt2560_init(sc); - - return 0; + if (error == ENETRESET) { + if ((ifp->if_flags & IFF_UP) && + (ifp->if_drv_flags & IFF_DRV_RUNNING)) + rt2560_init(sc); + } + return error; } /* @@ -2042,6 +2057,28 @@ m_freem(m0); continue; } + if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && + (m0->m_flags & M_PWR_SAV) == 0) { + /* + * Station in power save mode; pass the frame + * to the 802.11 layer and continue. We'll get + * the frame back when the time is right. + */ + ieee80211_pwrsave(ni, m0); + /* + * If we're in power save mode 'cuz of a bg + * scan cancel it so the traffic can flow. + * The packet we just queued will automatically + * get sent when we drop out of power save. + * XXX locking + */ + if (ic->ic_flags & IEEE80211_F_SCAN) + ieee80211_cancel_scan(ic); + ieee80211_free_node(ni); + continue; + + } + BPF_MTAP(ifp, m0); m0 = ieee80211_encap(ic, m0, ni); @@ -2049,7 +2086,7 @@ ieee80211_free_node(ni); continue; } - + if (bpf_peers_present(ic->ic_rawbpf)) bpf_mtap(ic->ic_rawbpf, m0); @@ -2289,6 +2326,8 @@ rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040); rt2560_rf_write(sc, RAL_RF4, rt2560_rf5222[i].r4); break; + default: + printf("unknown ral rev=%d\n", sc->rf_rev); } if (ic->ic_state != IEEE80211_S_SCAN) { @@ -2306,6 +2345,18 @@ } } +static void +rt2560_set_channel(struct ieee80211com *ic) +{ + struct ifnet *ifp = ic->ic_ifp; + struct rt2560_softc *sc = ifp->if_softc; + + RAL_LOCK(sc); + rt2560_set_chan(sc, ic->ic_curchan); + RAL_UNLOCK(sc); + +} + #if 0 /* * Disable RF auto-tuning. @@ -2450,7 +2501,7 @@ } static void -rt2560_set_bssid(struct rt2560_softc *sc, uint8_t *bssid) +rt2560_set_bssid(struct rt2560_softc *sc, const uint8_t *bssid) { uint32_t tmp; @@ -2555,6 +2606,30 @@ } } + +static void +rt2560_scan_start(struct ieee80211com *ic) +{ + struct ifnet *ifp = ic->ic_ifp; + struct rt2560_softc *sc = ifp->if_softc; + + printf("starting scan\n"); + /* abort TSF synchronization */ + RAL_WRITE(sc, RT2560_CSR14, 0); + rt2560_set_bssid(sc, ifp->if_broadcastaddr); +} + +static void +rt2560_scan_end(struct ieee80211com *ic) +{ + struct ifnet *ifp = ic->ic_ifp; + struct rt2560_softc *sc = ifp->if_softc; + printf("ending scan\n"); + rt2560_enable_tsf_sync(sc); + /* XXX keep local copy */ + rt2560_set_bssid(sc, ic->ic_bss->ni_bssid); +} + static int rt2560_bbp_init(struct rt2560_softc *sc) {