1/* $FreeBSD: head/sys/dev/ral/rt2560.c 172211 2007-09-17 19:07:24Z sam $ */
2
3/*-
4 * Copyright (c) 2005, 2006
5 * Damien Bergamini <damien.bergamini@free.fr>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <sys/cdefs.h>
21__FBSDID("$FreeBSD: head/sys/dev/ral/rt2560.c 172211 2007-09-17 19:07:24Z sam $");
22
23/*-
24 * Ralink Technology RT2560 chipset driver
25 * http://www.ralinktech.com/
26 */
27
28#include <sys/param.h>
29#include <sys/sysctl.h>
--- 70 unchanged lines hidden (view full) ---
100static int rt2560_newstate(struct ieee80211com *,
101 enum ieee80211_state, int);
102static uint16_t rt2560_eeprom_read(struct rt2560_softc *, uint8_t);
103static void rt2560_encryption_intr(struct rt2560_softc *);
104static void rt2560_tx_intr(struct rt2560_softc *);
105static void rt2560_prio_intr(struct rt2560_softc *);
106static void rt2560_decryption_intr(struct rt2560_softc *);
107static void rt2560_rx_intr(struct rt2560_softc *);
108static void rt2560_beacon_update(struct ieee80211com *, int item);
109static void rt2560_beacon_expire(struct rt2560_softc *);
110static void rt2560_wakeup_expire(struct rt2560_softc *);
111static uint8_t rt2560_rxrate(struct rt2560_rx_desc *);
112static int rt2560_ack_rate(struct ieee80211com *, int);
113static void rt2560_scan_start(struct ieee80211com *);
114static void rt2560_scan_end(struct ieee80211com *);
115static void rt2560_set_channel(struct ieee80211com *);
116static uint16_t rt2560_txtime(int, int, uint32_t);
--- 180 unchanged lines hidden (view full) ---
297 ic->ic_reset = rt2560_reset;
298 /* enable s/w bmiss handling in sta mode */
299 ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS;
300
301 /* override state transition machine */
302 sc->sc_newstate = ic->ic_newstate;
303 ic->ic_newstate = rt2560_newstate;
304 ic->ic_raw_xmit = rt2560_raw_xmit;
305 ic->ic_update_beacon = rt2560_beacon_update;
306 ieee80211_media_init(ic, rt2560_media_change, ieee80211_media_status);
307
308 bpfattach2(ifp, DLT_IEEE802_11_RADIO,
309 sizeof (struct ieee80211_frame) + sizeof (sc->sc_txtap),
310 &sc->sc_drvbpf);
311
312 sc->sc_rxtap_len = sizeof sc->sc_rxtap;
313 sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
--- 463 unchanged lines hidden (view full) ---
777 if (ic->ic_opmode != IEEE80211_M_MONITOR) {
778 rt2560_update_plcp(sc);
779 rt2560_set_basicrates(sc);
780 rt2560_set_bssid(sc, ni->ni_bssid);
781 }
782
783 if (ic->ic_opmode == IEEE80211_M_HOSTAP ||
784 ic->ic_opmode == IEEE80211_M_IBSS) {
785 m = ieee80211_beacon_alloc(ni, &sc->sc_bo);
786 if (m == NULL) {
787 device_printf(sc->sc_dev,
788 "could not allocate beacon\n");
789 error = ENOBUFS;
790 break;
791 }
792
793 ieee80211_ref_node(ni);
--- 480 unchanged lines hidden (view full) ---
1274
1275 bus_dmamap_sync(sc->rxq.desc_dmat, sc->rxq.desc_map,
1276 BUS_DMASYNC_PREWRITE);
1277
1278 /* kick decrypt */
1279 RAL_WRITE(sc, RT2560_SECCSR0, RT2560_KICK_DECRYPT);
1280}
1281
1282static void
1283rt2560_beacon_update(struct ieee80211com *ic, int item)
1284{
1285 struct rt2560_softc *sc = ic->ic_ifp->if_softc;
1286 struct ieee80211_beacon_offsets *bo = &sc->sc_bo;
1287
1288 setbit(bo->bo_flags, item);
1289}
1290
1291/*
1292 * This function is called periodically in IBSS mode when a new beacon must be
1293 * sent out.
1294 */
1295static void
1296rt2560_beacon_expire(struct rt2560_softc *sc)
1297{
1298 struct ieee80211com *ic = &sc->sc_ic;
--- 8 unchanged lines hidden (view full) ---
1307 * Don't send beacon if bsschan isn't set
1308 */
1309 if (data->ni == NULL)
1310 return;
1311
1312 bus_dmamap_sync(sc->bcnq.data_dmat, data->map, BUS_DMASYNC_POSTWRITE);
1313 bus_dmamap_unload(sc->bcnq.data_dmat, data->map);
1314
1315 ieee80211_beacon_update(data->ni, &sc->sc_bo, data->m, 1);
1316
1317 if (bpf_peers_present(ic->ic_rawbpf))
1318 bpf_mtap(ic->ic_rawbpf, data->m);
1319
1320 rt2560_tx_bcn(sc, data->m, data->ni);
1321
1322 DPRINTFN(15, ("beacon expired\n"));
1323
--- 1571 unchanged lines hidden ---
2
3/*-
4 * Copyright (c) 2005, 2006
5 * Damien Bergamini <damien.bergamini@free.fr>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <sys/cdefs.h>
21__FBSDID("$FreeBSD: head/sys/dev/ral/rt2560.c 172211 2007-09-17 19:07:24Z sam $");
22
23/*-
24 * Ralink Technology RT2560 chipset driver
25 * http://www.ralinktech.com/
26 */
27
28#include <sys/param.h>
29#include <sys/sysctl.h>
--- 70 unchanged lines hidden (view full) ---
100static int rt2560_newstate(struct ieee80211com *,
101 enum ieee80211_state, int);
102static uint16_t rt2560_eeprom_read(struct rt2560_softc *, uint8_t);
103static void rt2560_encryption_intr(struct rt2560_softc *);
104static void rt2560_tx_intr(struct rt2560_softc *);
105static void rt2560_prio_intr(struct rt2560_softc *);
106static void rt2560_decryption_intr(struct rt2560_softc *);
107static void rt2560_rx_intr(struct rt2560_softc *);
108static void rt2560_beacon_update(struct ieee80211com *, int item);
109static void rt2560_beacon_expire(struct rt2560_softc *);
110static void rt2560_wakeup_expire(struct rt2560_softc *);
111static uint8_t rt2560_rxrate(struct rt2560_rx_desc *);
112static int rt2560_ack_rate(struct ieee80211com *, int);
113static void rt2560_scan_start(struct ieee80211com *);
114static void rt2560_scan_end(struct ieee80211com *);
115static void rt2560_set_channel(struct ieee80211com *);
116static uint16_t rt2560_txtime(int, int, uint32_t);
--- 180 unchanged lines hidden (view full) ---
297 ic->ic_reset = rt2560_reset;
298 /* enable s/w bmiss handling in sta mode */
299 ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS;
300
301 /* override state transition machine */
302 sc->sc_newstate = ic->ic_newstate;
303 ic->ic_newstate = rt2560_newstate;
304 ic->ic_raw_xmit = rt2560_raw_xmit;
305 ic->ic_update_beacon = rt2560_beacon_update;
306 ieee80211_media_init(ic, rt2560_media_change, ieee80211_media_status);
307
308 bpfattach2(ifp, DLT_IEEE802_11_RADIO,
309 sizeof (struct ieee80211_frame) + sizeof (sc->sc_txtap),
310 &sc->sc_drvbpf);
311
312 sc->sc_rxtap_len = sizeof sc->sc_rxtap;
313 sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
--- 463 unchanged lines hidden (view full) ---
777 if (ic->ic_opmode != IEEE80211_M_MONITOR) {
778 rt2560_update_plcp(sc);
779 rt2560_set_basicrates(sc);
780 rt2560_set_bssid(sc, ni->ni_bssid);
781 }
782
783 if (ic->ic_opmode == IEEE80211_M_HOSTAP ||
784 ic->ic_opmode == IEEE80211_M_IBSS) {
785 m = ieee80211_beacon_alloc(ni, &sc->sc_bo);
786 if (m == NULL) {
787 device_printf(sc->sc_dev,
788 "could not allocate beacon\n");
789 error = ENOBUFS;
790 break;
791 }
792
793 ieee80211_ref_node(ni);
--- 480 unchanged lines hidden (view full) ---
1274
1275 bus_dmamap_sync(sc->rxq.desc_dmat, sc->rxq.desc_map,
1276 BUS_DMASYNC_PREWRITE);
1277
1278 /* kick decrypt */
1279 RAL_WRITE(sc, RT2560_SECCSR0, RT2560_KICK_DECRYPT);
1280}
1281
1282static void
1283rt2560_beacon_update(struct ieee80211com *ic, int item)
1284{
1285 struct rt2560_softc *sc = ic->ic_ifp->if_softc;
1286 struct ieee80211_beacon_offsets *bo = &sc->sc_bo;
1287
1288 setbit(bo->bo_flags, item);
1289}
1290
1291/*
1292 * This function is called periodically in IBSS mode when a new beacon must be
1293 * sent out.
1294 */
1295static void
1296rt2560_beacon_expire(struct rt2560_softc *sc)
1297{
1298 struct ieee80211com *ic = &sc->sc_ic;
--- 8 unchanged lines hidden (view full) ---
1307 * Don't send beacon if bsschan isn't set
1308 */
1309 if (data->ni == NULL)
1310 return;
1311
1312 bus_dmamap_sync(sc->bcnq.data_dmat, data->map, BUS_DMASYNC_POSTWRITE);
1313 bus_dmamap_unload(sc->bcnq.data_dmat, data->map);
1314
1315 ieee80211_beacon_update(data->ni, &sc->sc_bo, data->m, 1);
1316
1317 if (bpf_peers_present(ic->ic_rawbpf))
1318 bpf_mtap(ic->ic_rawbpf, data->m);
1319
1320 rt2560_tx_bcn(sc, data->m, data->ni);
1321
1322 DPRINTFN(15, ("beacon expired\n"));
1323
--- 1571 unchanged lines hidden ---