Deleted Added
full compact
if_rum.c (288622) if_rum.c (288623)
1/* $FreeBSD: head/sys/dev/usb/wlan/if_rum.c 288622 2015-10-03 17:34:11Z adrian $ */
1/* $FreeBSD: head/sys/dev/usb/wlan/if_rum.c 288623 2015-10-03 17:49:11Z adrian $ */
2
3/*-
4 * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr>
5 * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
6 * Copyright (c) 2007-2008 Hans Petter Selasky <hselasky@FreeBSD.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above

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

14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#include <sys/cdefs.h>
2
3/*-
4 * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr>
5 * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
6 * Copyright (c) 2007-2008 Hans Petter Selasky <hselasky@FreeBSD.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above

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

14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_rum.c 288622 2015-10-03 17:34:11Z adrian $");
22__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_rum.c 288623 2015-10-03 17:49:11Z adrian $");
23
24/*-
25 * Ralink Technology RT2501USB/RT2601USB chipset driver
26 * http://www.ralinktech.com.tw/
27 */
28
29#include <sys/param.h>
30#include <sys/sockio.h>

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

216static const char *rum_get_rf(int);
217static void rum_read_eeprom(struct rum_softc *);
218static int rum_bbp_wakeup(struct rum_softc *);
219static int rum_bbp_init(struct rum_softc *);
220static int rum_init(struct rum_softc *);
221static void rum_stop(struct rum_softc *);
222static void rum_load_microcode(struct rum_softc *, const uint8_t *,
223 size_t);
23
24/*-
25 * Ralink Technology RT2501USB/RT2601USB chipset driver
26 * http://www.ralinktech.com.tw/
27 */
28
29#include <sys/param.h>
30#include <sys/sockio.h>

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

216static const char *rum_get_rf(int);
217static void rum_read_eeprom(struct rum_softc *);
218static int rum_bbp_wakeup(struct rum_softc *);
219static int rum_bbp_init(struct rum_softc *);
220static int rum_init(struct rum_softc *);
221static void rum_stop(struct rum_softc *);
222static void rum_load_microcode(struct rum_softc *, const uint8_t *,
223 size_t);
224static int rum_prepare_beacon(struct rum_softc *,
224static int rum_set_beacon(struct rum_softc *,
225 struct ieee80211vap *);
225 struct ieee80211vap *);
226static int rum_alloc_beacon(struct rum_softc *,
227 struct ieee80211vap *);
226static int rum_raw_xmit(struct ieee80211_node *, struct mbuf *,
227 const struct ieee80211_bpf_params *);
228static void rum_scan_start(struct ieee80211com *);
229static void rum_scan_end(struct ieee80211com *);
230static void rum_set_channel(struct ieee80211com *);
231static int rum_get_rssi(struct rum_softc *, uint8_t);
232static void rum_ratectl_start(struct rum_softc *,
233 struct ieee80211_node *);

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

625}
626
627static void
628rum_vap_delete(struct ieee80211vap *vap)
629{
630 struct rum_vap *rvp = RUM_VAP(vap);
631 struct ieee80211com *ic = vap->iv_ic;
632
228static int rum_raw_xmit(struct ieee80211_node *, struct mbuf *,
229 const struct ieee80211_bpf_params *);
230static void rum_scan_start(struct ieee80211com *);
231static void rum_scan_end(struct ieee80211com *);
232static void rum_set_channel(struct ieee80211com *);
233static int rum_get_rssi(struct rum_softc *, uint8_t);
234static void rum_ratectl_start(struct rum_softc *,
235 struct ieee80211_node *);

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

627}
628
629static void
630rum_vap_delete(struct ieee80211vap *vap)
631{
632 struct rum_vap *rvp = RUM_VAP(vap);
633 struct ieee80211com *ic = vap->iv_ic;
634
635 m_freem(rvp->bcn_mbuf);
633 usb_callout_drain(&rvp->ratectl_ch);
634 ieee80211_draintask(ic, &rvp->ratectl_task);
635 ieee80211_ratectl_deinit(vap);
636 ieee80211_vap_detach(vap);
637 free(rvp, M_80211_VAP);
638}
639
640static void

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

787 rum_set_txpreamble(sc);
788 rum_set_basicrates(sc);
789 IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid);
790 rum_set_bssid(sc, sc->sc_bssid);
791 }
792
793 if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
794 vap->iv_opmode == IEEE80211_M_IBSS) {
636 usb_callout_drain(&rvp->ratectl_ch);
637 ieee80211_draintask(ic, &rvp->ratectl_task);
638 ieee80211_ratectl_deinit(vap);
639 ieee80211_vap_detach(vap);
640 free(rvp, M_80211_VAP);
641}
642
643static void

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

790 rum_set_txpreamble(sc);
791 rum_set_basicrates(sc);
792 IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid);
793 rum_set_bssid(sc, sc->sc_bssid);
794 }
795
796 if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
797 vap->iv_opmode == IEEE80211_M_IBSS) {
795 if ((ret = rum_prepare_beacon(sc, vap)) != 0)
798 if ((ret = rum_alloc_beacon(sc, vap)) != 0)
796 goto run_fail;
797 }
798
799 if (vap->iv_opmode != IEEE80211_M_MONITOR &&
800 vap->iv_opmode != IEEE80211_M_AHDEMO) {
801 if ((ret = rum_enable_tsf_sync(sc)) != 0)
802 goto run_fail;
803 } else

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

2203 usbd_errstr(err));
2204 }
2205
2206 /* give the chip some time to boot */
2207 rum_pause(sc, hz / 8);
2208}
2209
2210static int
799 goto run_fail;
800 }
801
802 if (vap->iv_opmode != IEEE80211_M_MONITOR &&
803 vap->iv_opmode != IEEE80211_M_AHDEMO) {
804 if ((ret = rum_enable_tsf_sync(sc)) != 0)
805 goto run_fail;
806 } else

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

2206 usbd_errstr(err));
2207 }
2208
2209 /* give the chip some time to boot */
2210 rum_pause(sc, hz / 8);
2211}
2212
2213static int
2211rum_prepare_beacon(struct rum_softc *sc, struct ieee80211vap *vap)
2214rum_set_beacon(struct rum_softc *sc, struct ieee80211vap *vap)
2212{
2213 struct ieee80211com *ic = vap->iv_ic;
2215{
2216 struct ieee80211com *ic = vap->iv_ic;
2217 struct rum_vap *rvp = RUM_VAP(vap);
2218 struct mbuf *m = rvp->bcn_mbuf;
2214 const struct ieee80211_txparam *tp;
2215 struct rum_tx_desc desc;
2219 const struct ieee80211_txparam *tp;
2220 struct rum_tx_desc desc;
2216 struct mbuf *m0;
2217 int ret = 0;
2218
2221
2219 if (vap->iv_bss->ni_chan == IEEE80211_CHAN_ANYC)
2222 RUM_LOCK_ASSERT(sc);
2223
2224 if (m == NULL)
2220 return EINVAL;
2221 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC)
2222 return EINVAL;
2223
2225 return EINVAL;
2226 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC)
2227 return EINVAL;
2228
2224 m0 = ieee80211_beacon_alloc(vap->iv_bss, &vap->iv_bcn_off);
2225 if (m0 == NULL)
2226 return ENOMEM;
2227
2228 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_bsschan)];
2229 rum_setup_tx_desc(sc, &desc, RT2573_TX_TIMESTAMP, RT2573_TX_HWSEQ,
2229 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_bsschan)];
2230 rum_setup_tx_desc(sc, &desc, RT2573_TX_TIMESTAMP, RT2573_TX_HWSEQ,
2230 m0->m_pkthdr.len, tp->mgmtrate);
2231 m->m_pkthdr.len, tp->mgmtrate);
2231
2232
2232 /* copy the first 24 bytes of Tx descriptor into NIC memory */
2233 if ((ret = rum_write_multi(sc, RT2573_HW_BEACON_BASE0,
2234 (uint8_t *)&desc, 24)) != 0) {
2235 ret = EIO;
2236 goto end;
2237 }
2233 /* copy the Tx descriptor into NIC memory */
2234 if (rum_write_multi(sc, RT2573_HW_BCN_BASE(0), (uint8_t *)&desc,
2235 RT2573_TX_DESC_SIZE) != 0)
2236 return EIO;
2238
2239 /* copy beacon header and payload into NIC memory */
2237
2238 /* copy beacon header and payload into NIC memory */
2240 if ((ret = rum_write_multi(sc, RT2573_HW_BEACON_BASE0 + 24, mtod(m0, uint8_t *),
2241 m0->m_pkthdr.len)) != 0)
2242 ret = EIO;
2239 if (rum_write_multi(sc, RT2573_HW_BCN_BASE(0) + RT2573_TX_DESC_SIZE,
2240 mtod(m, uint8_t *), m->m_pkthdr.len) != 0)
2241 return EIO;
2243
2242
2244end:
2245 m_freem(m0);
2246 return ret;
2243 return 0;
2247}
2248
2249static int
2244}
2245
2246static int
2247rum_alloc_beacon(struct rum_softc *sc, struct ieee80211vap *vap)
2248{
2249 struct rum_vap *rvp = RUM_VAP(vap);
2250 struct ieee80211_node *ni = vap->iv_bss;
2251 struct mbuf *m;
2252
2253 if (ni->ni_chan == IEEE80211_CHAN_ANYC)
2254 return EINVAL;
2255
2256 m = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off);
2257 if (m == NULL)
2258 return ENOMEM;
2259
2260 if (rvp->bcn_mbuf != NULL)
2261 m_freem(rvp->bcn_mbuf);
2262
2263 rvp->bcn_mbuf = m;
2264
2265 return (rum_set_beacon(sc, vap));
2266}
2267
2268static int
2250rum_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
2251 const struct ieee80211_bpf_params *params)
2252{
2253 struct rum_softc *sc = ni->ni_ic->ic_softc;
2254 int ret;
2255
2256 RUM_LOCK(sc);
2257 /* prevent management frames from being sent if we're not ready */

--- 200 unchanged lines hidden ---
2269rum_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
2270 const struct ieee80211_bpf_params *params)
2271{
2272 struct rum_softc *sc = ni->ni_ic->ic_softc;
2273 int ret;
2274
2275 RUM_LOCK(sc);
2276 /* prevent management frames from being sent if we're not ready */

--- 200 unchanged lines hidden ---