ralinkwifi: Sync with FreeBSD 11.1.
Untested, but the changes are mostly adapations to the new KPIs.
This commit is contained in:
@@ -6,7 +6,6 @@ SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8335 ;
|
|||||||
# FreeBSD 9.3 drivers
|
# FreeBSD 9.3 drivers
|
||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan broadcom43xx ;
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan broadcom43xx ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ;
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ;
|
|
||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan wavelanwifi ;
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan wavelanwifi ;
|
||||||
|
|
||||||
# FreeBSD 11.1 drivers
|
# FreeBSD 11.1 drivers
|
||||||
@@ -15,6 +14,7 @@ SubInclude HAIKU_TOP src add-ons kernel drivers network wlan atheroswifi ;
|
|||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi2100 ;
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi2100 ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi3945 ;
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi3945 ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi4965 ;
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi4965 ;
|
||||||
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ;
|
||||||
|
|
||||||
# FreeBSD 11.2 drivers
|
# FreeBSD 11.2 drivers
|
||||||
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan idualwifi7260 ;
|
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan idualwifi7260 ;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
SubDir HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ;
|
SubDir HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ;
|
||||||
|
|
||||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ]
|
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ]
|
||||||
: true ;
|
: true ;
|
||||||
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
|
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_wlan ] : true ;
|
||||||
UsePrivateHeaders net system ;
|
UsePrivateHeaders net system ;
|
||||||
UsePrivateKernelHeaders ;
|
UsePrivateKernelHeaders ;
|
||||||
|
|
||||||
@@ -22,8 +22,8 @@ KernelAddon ralinkwifi :
|
|||||||
rt2860.c
|
rt2860.c
|
||||||
glue.c
|
glue.c
|
||||||
:
|
:
|
||||||
libfreebsd_wlan.a
|
libfreebsd11_wlan.a
|
||||||
libfreebsd_network.a
|
libfreebsd11_network.a
|
||||||
;
|
;
|
||||||
|
|
||||||
HAIKU_WIFI_FIRMWARE_PACKAGES on ralinkwifi = RT61_Firmware_V1.2
|
HAIKU_WIFI_FIRMWARE_PACKAGES on ralinkwifi = RT61_Firmware_V1.2
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/if_ral_pci.c 287197 2015-08-27 08:56:39Z glebius $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PCI/Cardbus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
|
* PCI/Cardbus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
|
||||||
@@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/mbuf.h>
|
||||||
#include <sys/module.h>
|
#include <sys/module.h>
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
#include <sys/rman.h>
|
#include <sys/rman.h>
|
||||||
@@ -93,7 +94,10 @@ static const struct ral_pci_ident ral_pci_ids[] = {
|
|||||||
{ 0x1814, 0x3562, "Ralink Technology RT3562" },
|
{ 0x1814, 0x3562, "Ralink Technology RT3562" },
|
||||||
{ 0x1814, 0x3592, "Ralink Technology RT3592" },
|
{ 0x1814, 0x3592, "Ralink Technology RT3592" },
|
||||||
{ 0x1814, 0x3593, "Ralink Technology RT3593" },
|
{ 0x1814, 0x3593, "Ralink Technology RT3593" },
|
||||||
|
{ 0x1814, 0x5360, "Ralink Technology RT5390" },
|
||||||
|
{ 0x1814, 0x5362, "Ralink Technology RT5392" },
|
||||||
{ 0x1814, 0x5390, "Ralink Technology RT5390" },
|
{ 0x1814, 0x5390, "Ralink Technology RT5390" },
|
||||||
|
{ 0x1814, 0x5392, "Ralink Technology RT5392" },
|
||||||
{ 0x1814, 0x539a, "Ralink Technology RT5390" },
|
{ 0x1814, 0x539a, "Ralink Technology RT5390" },
|
||||||
{ 0x1814, 0x539f, "Ralink Technology RT5390" },
|
{ 0x1814, 0x539f, "Ralink Technology RT5390" },
|
||||||
{ 0x1a3b, 0x1059, "AWT RT2890" },
|
{ 0x1a3b, 0x1059, "AWT RT2890" },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2560.c 300752 2016-05-26 16:05:19Z avos $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005, 2006
|
* Copyright (c) 2005, 2006
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/rt2560.c 300752 2016-05-26 16:05:19Z avos $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Ralink Technology RT2560 chipset driver
|
* Ralink Technology RT2560 chipset driver
|
||||||
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <net/if_var.h>
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
#include <net/if_dl.h>
|
#include <net/if_dl.h>
|
||||||
@@ -116,6 +117,8 @@ static void rt2560_beacon_expire(struct rt2560_softc *);
|
|||||||
static void rt2560_wakeup_expire(struct rt2560_softc *);
|
static void rt2560_wakeup_expire(struct rt2560_softc *);
|
||||||
static void rt2560_scan_start(struct ieee80211com *);
|
static void rt2560_scan_start(struct ieee80211com *);
|
||||||
static void rt2560_scan_end(struct ieee80211com *);
|
static void rt2560_scan_end(struct ieee80211com *);
|
||||||
|
static void rt2560_getradiocaps(struct ieee80211com *, int, int *,
|
||||||
|
struct ieee80211_channel[]);
|
||||||
static void rt2560_set_channel(struct ieee80211com *);
|
static void rt2560_set_channel(struct ieee80211com *);
|
||||||
static void rt2560_setup_tx_desc(struct rt2560_softc *,
|
static void rt2560_setup_tx_desc(struct rt2560_softc *,
|
||||||
struct rt2560_tx_desc *, uint32_t, int, int, int,
|
struct rt2560_tx_desc *, uint32_t, int, int, int,
|
||||||
@@ -126,10 +129,10 @@ static int rt2560_tx_mgt(struct rt2560_softc *, struct mbuf *,
|
|||||||
struct ieee80211_node *);
|
struct ieee80211_node *);
|
||||||
static int rt2560_tx_data(struct rt2560_softc *, struct mbuf *,
|
static int rt2560_tx_data(struct rt2560_softc *, struct mbuf *,
|
||||||
struct ieee80211_node *);
|
struct ieee80211_node *);
|
||||||
static void rt2560_start_locked(struct ifnet *);
|
static int rt2560_transmit(struct ieee80211com *, struct mbuf *);
|
||||||
static void rt2560_start(struct ifnet *);
|
static void rt2560_start(struct rt2560_softc *);
|
||||||
static void rt2560_watchdog(void *);
|
static void rt2560_watchdog(void *);
|
||||||
static int rt2560_ioctl(struct ifnet *, u_long, caddr_t);
|
static void rt2560_parent(struct ieee80211com *);
|
||||||
static void rt2560_bbp_write(struct rt2560_softc *, uint8_t,
|
static void rt2560_bbp_write(struct rt2560_softc *, uint8_t,
|
||||||
uint8_t);
|
uint8_t);
|
||||||
static uint8_t rt2560_bbp_read(struct rt2560_softc *, uint8_t);
|
static uint8_t rt2560_bbp_read(struct rt2560_softc *, uint8_t);
|
||||||
@@ -143,14 +146,15 @@ static void rt2560_disable_rf_tune(struct rt2560_softc *);
|
|||||||
static void rt2560_enable_tsf_sync(struct rt2560_softc *);
|
static void rt2560_enable_tsf_sync(struct rt2560_softc *);
|
||||||
static void rt2560_enable_tsf(struct rt2560_softc *);
|
static void rt2560_enable_tsf(struct rt2560_softc *);
|
||||||
static void rt2560_update_plcp(struct rt2560_softc *);
|
static void rt2560_update_plcp(struct rt2560_softc *);
|
||||||
static void rt2560_update_slot(struct ifnet *);
|
static void rt2560_update_slot(struct ieee80211com *);
|
||||||
static void rt2560_set_basicrates(struct rt2560_softc *,
|
static void rt2560_set_basicrates(struct rt2560_softc *,
|
||||||
const struct ieee80211_rateset *);
|
const struct ieee80211_rateset *);
|
||||||
static void rt2560_update_led(struct rt2560_softc *, int, int);
|
static void rt2560_update_led(struct rt2560_softc *, int, int);
|
||||||
static void rt2560_set_bssid(struct rt2560_softc *, const 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_set_macaddr(struct rt2560_softc *,
|
||||||
|
const uint8_t *);
|
||||||
static void rt2560_get_macaddr(struct rt2560_softc *, uint8_t *);
|
static void rt2560_get_macaddr(struct rt2560_softc *, uint8_t *);
|
||||||
static void rt2560_update_promisc(struct ifnet *);
|
static void rt2560_update_promisc(struct ieee80211com *);
|
||||||
static const char *rt2560_get_rf(int);
|
static const char *rt2560_get_rf(int);
|
||||||
static void rt2560_read_config(struct rt2560_softc *);
|
static void rt2560_read_config(struct rt2560_softc *);
|
||||||
static int rt2560_bbp_init(struct rt2560_softc *);
|
static int rt2560_bbp_init(struct rt2560_softc *);
|
||||||
@@ -185,6 +189,14 @@ static const uint32_t rt2560_rf2525e_r2[] = RT2560_RF2525E_R2;
|
|||||||
static const uint32_t rt2560_rf2526_r2[] = RT2560_RF2526_R2;
|
static const uint32_t rt2560_rf2526_r2[] = RT2560_RF2526_R2;
|
||||||
static const uint32_t rt2560_rf2526_hi_r2[] = RT2560_RF2526_HI_R2;
|
static const uint32_t rt2560_rf2526_hi_r2[] = RT2560_RF2526_HI_R2;
|
||||||
|
|
||||||
|
static const uint8_t rt2560_chan_2ghz[] =
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
|
||||||
|
|
||||||
|
static const uint8_t rt2560_chan_5ghz[] =
|
||||||
|
{ 36, 40, 44, 48, 52, 56, 60, 64,
|
||||||
|
100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
|
||||||
|
149, 153, 157, 161 };
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
uint8_t chan;
|
uint8_t chan;
|
||||||
uint32_t r1, r2, r4;
|
uint32_t r1, r2, r4;
|
||||||
@@ -196,11 +208,8 @@ int
|
|||||||
rt2560_attach(device_t dev, int id)
|
rt2560_attach(device_t dev, int id)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = device_get_softc(dev);
|
struct rt2560_softc *sc = device_get_softc(dev);
|
||||||
struct ieee80211com *ic;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ifnet *ifp;
|
|
||||||
int error;
|
int error;
|
||||||
uint8_t bands;
|
|
||||||
uint8_t macaddr[IEEE80211_ADDR_LEN];
|
|
||||||
|
|
||||||
sc->sc_dev = dev;
|
sc->sc_dev = dev;
|
||||||
|
|
||||||
@@ -208,6 +217,7 @@ rt2560_attach(device_t dev, int id)
|
|||||||
MTX_DEF | MTX_RECURSE);
|
MTX_DEF | MTX_RECURSE);
|
||||||
|
|
||||||
callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
|
callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
|
||||||
|
mbufq_init(&sc->sc_snd, ifqmaxlen);
|
||||||
|
|
||||||
/* retrieve RT2560 rev. no */
|
/* retrieve RT2560 rev. no */
|
||||||
sc->asic_rev = RAL_READ(sc, RT2560_CSR0);
|
sc->asic_rev = RAL_READ(sc, RT2560_CSR0);
|
||||||
@@ -251,27 +261,11 @@ rt2560_attach(device_t dev, int id)
|
|||||||
goto fail5;
|
goto fail5;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
|
|
||||||
if (ifp == NULL) {
|
|
||||||
device_printf(sc->sc_dev, "can not if_alloc()\n");
|
|
||||||
goto fail6;
|
|
||||||
}
|
|
||||||
ic = ifp->if_l2com;
|
|
||||||
|
|
||||||
/* retrieve MAC address */
|
/* retrieve MAC address */
|
||||||
rt2560_get_macaddr(sc, macaddr);
|
rt2560_get_macaddr(sc, ic->ic_macaddr);
|
||||||
|
|
||||||
ifp->if_softc = sc;
|
ic->ic_softc = sc;
|
||||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
ic->ic_name = device_get_nameunit(dev);
|
||||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
|
||||||
ifp->if_init = rt2560_init;
|
|
||||||
ifp->if_ioctl = rt2560_ioctl;
|
|
||||||
ifp->if_start = rt2560_start;
|
|
||||||
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
|
|
||||||
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
|
|
||||||
IFQ_SET_READY(&ifp->if_snd);
|
|
||||||
|
|
||||||
ic->ic_ifp = ifp;
|
|
||||||
ic->ic_opmode = IEEE80211_M_STA;
|
ic->ic_opmode = IEEE80211_M_STA;
|
||||||
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
|
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
|
||||||
|
|
||||||
@@ -293,23 +287,22 @@ rt2560_attach(device_t dev, int id)
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
bands = 0;
|
rt2560_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
|
||||||
setbit(&bands, IEEE80211_MODE_11B);
|
ic->ic_channels);
|
||||||
setbit(&bands, IEEE80211_MODE_11G);
|
|
||||||
if (sc->rf_rev == RT2560_RF_5222)
|
|
||||||
setbit(&bands, IEEE80211_MODE_11A);
|
|
||||||
ieee80211_init_channels(ic, NULL, &bands);
|
|
||||||
|
|
||||||
ieee80211_ifattach(ic, macaddr);
|
ieee80211_ifattach(ic);
|
||||||
ic->ic_raw_xmit = rt2560_raw_xmit;
|
ic->ic_raw_xmit = rt2560_raw_xmit;
|
||||||
ic->ic_updateslot = rt2560_update_slot;
|
ic->ic_updateslot = rt2560_update_slot;
|
||||||
ic->ic_update_promisc = rt2560_update_promisc;
|
ic->ic_update_promisc = rt2560_update_promisc;
|
||||||
ic->ic_scan_start = rt2560_scan_start;
|
ic->ic_scan_start = rt2560_scan_start;
|
||||||
ic->ic_scan_end = rt2560_scan_end;
|
ic->ic_scan_end = rt2560_scan_end;
|
||||||
|
ic->ic_getradiocaps = rt2560_getradiocaps;
|
||||||
ic->ic_set_channel = rt2560_set_channel;
|
ic->ic_set_channel = rt2560_set_channel;
|
||||||
|
|
||||||
ic->ic_vap_create = rt2560_vap_create;
|
ic->ic_vap_create = rt2560_vap_create;
|
||||||
ic->ic_vap_delete = rt2560_vap_delete;
|
ic->ic_vap_delete = rt2560_vap_delete;
|
||||||
|
ic->ic_parent = rt2560_parent;
|
||||||
|
ic->ic_transmit = rt2560_transmit;
|
||||||
|
|
||||||
ieee80211_radiotap_attach(ic,
|
ieee80211_radiotap_attach(ic,
|
||||||
&sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap),
|
&sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap),
|
||||||
@@ -338,7 +331,6 @@ rt2560_attach(device_t dev, int id)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail6: rt2560_free_rx_ring(sc, &sc->rxq);
|
|
||||||
fail5: rt2560_free_tx_ring(sc, &sc->bcnq);
|
fail5: rt2560_free_tx_ring(sc, &sc->bcnq);
|
||||||
fail4: rt2560_free_tx_ring(sc, &sc->prioq);
|
fail4: rt2560_free_tx_ring(sc, &sc->prioq);
|
||||||
fail3: rt2560_free_tx_ring(sc, &sc->atimq);
|
fail3: rt2560_free_tx_ring(sc, &sc->atimq);
|
||||||
@@ -352,12 +344,12 @@ int
|
|||||||
rt2560_detach(void *xsc)
|
rt2560_detach(void *xsc)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = xsc;
|
struct rt2560_softc *sc = xsc;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
|
|
||||||
rt2560_stop(sc);
|
rt2560_stop(sc);
|
||||||
|
|
||||||
ieee80211_ifdetach(ic);
|
ieee80211_ifdetach(ic);
|
||||||
|
mbufq_drain(&sc->sc_snd);
|
||||||
|
|
||||||
rt2560_free_tx_ring(sc, &sc->txq);
|
rt2560_free_tx_ring(sc, &sc->txq);
|
||||||
rt2560_free_tx_ring(sc, &sc->atimq);
|
rt2560_free_tx_ring(sc, &sc->atimq);
|
||||||
@@ -365,8 +357,6 @@ rt2560_detach(void *xsc)
|
|||||||
rt2560_free_tx_ring(sc, &sc->bcnq);
|
rt2560_free_tx_ring(sc, &sc->bcnq);
|
||||||
rt2560_free_rx_ring(sc, &sc->rxq);
|
rt2560_free_rx_ring(sc, &sc->rxq);
|
||||||
|
|
||||||
if_free(ifp);
|
|
||||||
|
|
||||||
mtx_destroy(&sc->sc_mtx);
|
mtx_destroy(&sc->sc_mtx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -378,7 +368,7 @@ rt2560_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
const uint8_t bssid[IEEE80211_ADDR_LEN],
|
const uint8_t bssid[IEEE80211_ADDR_LEN],
|
||||||
const uint8_t mac[IEEE80211_ADDR_LEN])
|
const uint8_t mac[IEEE80211_ADDR_LEN])
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct rt2560_vap *rvp;
|
struct rt2560_vap *rvp;
|
||||||
struct ieee80211vap *vap;
|
struct ieee80211vap *vap;
|
||||||
|
|
||||||
@@ -391,7 +381,7 @@ rt2560_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
case IEEE80211_M_MBSS:
|
case IEEE80211_M_MBSS:
|
||||||
/* XXXRP: TBD */
|
/* XXXRP: TBD */
|
||||||
if (!TAILQ_EMPTY(&ic->ic_vaps)) {
|
if (!TAILQ_EMPTY(&ic->ic_vaps)) {
|
||||||
if_printf(ifp, "only 1 vap supported\n");
|
device_printf(sc->sc_dev, "only 1 vap supported\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (opmode == IEEE80211_M_STA)
|
if (opmode == IEEE80211_M_STA)
|
||||||
@@ -400,7 +390,8 @@ rt2560_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
case IEEE80211_M_WDS:
|
case IEEE80211_M_WDS:
|
||||||
if (TAILQ_EMPTY(&ic->ic_vaps) ||
|
if (TAILQ_EMPTY(&ic->ic_vaps) ||
|
||||||
ic->ic_opmode != IEEE80211_M_HOSTAP) {
|
ic->ic_opmode != IEEE80211_M_HOSTAP) {
|
||||||
if_printf(ifp, "wds only supported in ap mode\n");
|
device_printf(sc->sc_dev,
|
||||||
|
"wds only supported in ap mode\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -411,15 +402,12 @@ rt2560_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
flags &= ~IEEE80211_CLONE_BSSID;
|
flags &= ~IEEE80211_CLONE_BSSID;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if_printf(ifp, "unknown opmode %d\n", opmode);
|
device_printf(sc->sc_dev, "unknown opmode %d\n", opmode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rvp = (struct rt2560_vap *) malloc(sizeof(struct rt2560_vap),
|
rvp = malloc(sizeof(struct rt2560_vap), M_80211_VAP, M_WAITOK | M_ZERO);
|
||||||
M_80211_VAP, M_NOWAIT | M_ZERO);
|
|
||||||
if (rvp == NULL)
|
|
||||||
return NULL;
|
|
||||||
vap = &rvp->ral_vap;
|
vap = &rvp->ral_vap;
|
||||||
ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac);
|
ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid);
|
||||||
|
|
||||||
/* override state transition machine */
|
/* override state transition machine */
|
||||||
rvp->ral_newstate = vap->iv_newstate;
|
rvp->ral_newstate = vap->iv_newstate;
|
||||||
@@ -428,7 +416,8 @@ rt2560_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
|
|
||||||
ieee80211_ratectl_init(vap);
|
ieee80211_ratectl_init(vap);
|
||||||
/* complete setup */
|
/* complete setup */
|
||||||
ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status);
|
ieee80211_vap_attach(vap, ieee80211_media_change,
|
||||||
|
ieee80211_media_status, mac);
|
||||||
if (TAILQ_FIRST(&ic->ic_vaps) == vap)
|
if (TAILQ_FIRST(&ic->ic_vaps) == vap)
|
||||||
ic->ic_opmode = opmode;
|
ic->ic_opmode = opmode;
|
||||||
return vap;
|
return vap;
|
||||||
@@ -448,9 +437,8 @@ void
|
|||||||
rt2560_resume(void *xsc)
|
rt2560_resume(void *xsc)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = xsc;
|
struct rt2560_softc *sc = xsc;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
|
|
||||||
if (ifp->if_flags & IFF_UP)
|
if (sc->sc_ic.ic_nrunning > 0)
|
||||||
rt2560_init(sc);
|
rt2560_init(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,8 +748,7 @@ static int
|
|||||||
rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
||||||
{
|
{
|
||||||
struct rt2560_vap *rvp = RT2560_VAP(vap);
|
struct rt2560_vap *rvp = RT2560_VAP(vap);
|
||||||
struct ifnet *ifp = vap->iv_ic->ic_ifp;
|
struct rt2560_softc *sc = vap->iv_ic->ic_softc;
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
|
if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
|
||||||
@@ -787,9 +774,10 @@ rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
|||||||
if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
|
if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
|
||||||
vap->iv_opmode == IEEE80211_M_IBSS ||
|
vap->iv_opmode == IEEE80211_M_IBSS ||
|
||||||
vap->iv_opmode == IEEE80211_M_MBSS) {
|
vap->iv_opmode == IEEE80211_M_MBSS) {
|
||||||
m = ieee80211_beacon_alloc(ni, &rvp->ral_bo);
|
m = ieee80211_beacon_alloc(ni);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
if_printf(ifp, "could not allocate beacon\n");
|
device_printf(sc->sc_dev,
|
||||||
|
"could not allocate beacon\n");
|
||||||
return ENOBUFS;
|
return ENOBUFS;
|
||||||
}
|
}
|
||||||
ieee80211_ref_node(ni);
|
ieee80211_ref_node(ni);
|
||||||
@@ -798,7 +786,7 @@ rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* turn assocation led on */
|
/* turn association led on */
|
||||||
rt2560_update_led(sc, 1, 0);
|
rt2560_update_led(sc, 1, 0);
|
||||||
|
|
||||||
if (vap->iv_opmode != IEEE80211_M_MONITOR)
|
if (vap->iv_opmode != IEEE80211_M_MONITOR)
|
||||||
@@ -923,14 +911,13 @@ rt2560_encryption_intr(struct rt2560_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2560_tx_intr(struct rt2560_softc *sc)
|
rt2560_tx_intr(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
struct rt2560_tx_desc *desc;
|
struct rt2560_tx_desc *desc;
|
||||||
struct rt2560_tx_data *data;
|
struct rt2560_tx_data *data;
|
||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
uint32_t flags;
|
|
||||||
int retrycnt;
|
|
||||||
struct ieee80211vap *vap;
|
struct ieee80211vap *vap;
|
||||||
struct ieee80211_node *ni;
|
struct ieee80211_node *ni;
|
||||||
|
uint32_t flags;
|
||||||
|
int retrycnt, status;
|
||||||
|
|
||||||
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
|
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
|
||||||
BUS_DMASYNC_POSTREAD);
|
BUS_DMASYNC_POSTREAD);
|
||||||
@@ -958,7 +945,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
|
|||||||
ieee80211_ratectl_tx_complete(vap, ni,
|
ieee80211_ratectl_tx_complete(vap, ni,
|
||||||
IEEE80211_RATECTL_TX_SUCCESS,
|
IEEE80211_RATECTL_TX_SUCCESS,
|
||||||
&retrycnt, NULL);
|
&retrycnt, NULL);
|
||||||
ifp->if_opackets++;
|
status = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RT2560_TX_SUCCESS_RETRY:
|
case RT2560_TX_SUCCESS_RETRY:
|
||||||
@@ -970,7 +957,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
|
|||||||
ieee80211_ratectl_tx_complete(vap, ni,
|
ieee80211_ratectl_tx_complete(vap, ni,
|
||||||
IEEE80211_RATECTL_TX_SUCCESS,
|
IEEE80211_RATECTL_TX_SUCCESS,
|
||||||
&retrycnt, NULL);
|
&retrycnt, NULL);
|
||||||
ifp->if_opackets++;
|
status = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RT2560_TX_FAIL_RETRY:
|
case RT2560_TX_FAIL_RETRY:
|
||||||
@@ -982,7 +969,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
|
|||||||
ieee80211_ratectl_tx_complete(vap, ni,
|
ieee80211_ratectl_tx_complete(vap, ni,
|
||||||
IEEE80211_RATECTL_TX_FAILURE,
|
IEEE80211_RATECTL_TX_FAILURE,
|
||||||
&retrycnt, NULL);
|
&retrycnt, NULL);
|
||||||
ifp->if_oerrors++;
|
status = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RT2560_TX_FAIL_INVALID:
|
case RT2560_TX_FAIL_INVALID:
|
||||||
@@ -990,16 +977,16 @@ rt2560_tx_intr(struct rt2560_softc *sc)
|
|||||||
default:
|
default:
|
||||||
device_printf(sc->sc_dev, "sending data frame failed "
|
device_printf(sc->sc_dev, "sending data frame failed "
|
||||||
"0x%08x\n", flags);
|
"0x%08x\n", flags);
|
||||||
ifp->if_oerrors++;
|
status = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bus_dmamap_sync(sc->txq.data_dmat, data->map,
|
bus_dmamap_sync(sc->txq.data_dmat, data->map,
|
||||||
BUS_DMASYNC_POSTWRITE);
|
BUS_DMASYNC_POSTWRITE);
|
||||||
bus_dmamap_unload(sc->txq.data_dmat, data->map);
|
bus_dmamap_unload(sc->txq.data_dmat, data->map);
|
||||||
m_freem(m);
|
|
||||||
data->m = NULL;
|
ieee80211_tx_complete(ni, m, status);
|
||||||
ieee80211_free_node(data->ni);
|
|
||||||
data->ni = NULL;
|
data->ni = NULL;
|
||||||
|
data->m = NULL;
|
||||||
|
|
||||||
/* descriptor is no longer valid */
|
/* descriptor is no longer valid */
|
||||||
desc->flags &= ~htole32(RT2560_TX_VALID);
|
desc->flags &= ~htole32(RT2560_TX_VALID);
|
||||||
@@ -1016,19 +1003,13 @@ rt2560_tx_intr(struct rt2560_softc *sc)
|
|||||||
if (sc->prioq.queued == 0 && sc->txq.queued == 0)
|
if (sc->prioq.queued == 0 && sc->txq.queued == 0)
|
||||||
sc->sc_tx_timer = 0;
|
sc->sc_tx_timer = 0;
|
||||||
|
|
||||||
if (sc->txq.queued < RT2560_TX_RING_COUNT - 1) {
|
if (sc->txq.queued < RT2560_TX_RING_COUNT - 1)
|
||||||
sc->sc_flags &= ~RT2560_F_DATA_OACTIVE;
|
rt2560_start(sc);
|
||||||
if ((sc->sc_flags &
|
|
||||||
(RT2560_F_DATA_OACTIVE | RT2560_F_PRIO_OACTIVE)) == 0)
|
|
||||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
|
||||||
rt2560_start_locked(ifp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_prio_intr(struct rt2560_softc *sc)
|
rt2560_prio_intr(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
struct rt2560_tx_desc *desc;
|
struct rt2560_tx_desc *desc;
|
||||||
struct rt2560_tx_data *data;
|
struct rt2560_tx_data *data;
|
||||||
struct ieee80211_node *ni;
|
struct ieee80211_node *ni;
|
||||||
@@ -1100,13 +1081,8 @@ rt2560_prio_intr(struct rt2560_softc *sc)
|
|||||||
if (sc->prioq.queued == 0 && sc->txq.queued == 0)
|
if (sc->prioq.queued == 0 && sc->txq.queued == 0)
|
||||||
sc->sc_tx_timer = 0;
|
sc->sc_tx_timer = 0;
|
||||||
|
|
||||||
if (sc->prioq.queued < RT2560_PRIO_RING_COUNT) {
|
if (sc->prioq.queued < RT2560_PRIO_RING_COUNT)
|
||||||
sc->sc_flags &= ~RT2560_F_PRIO_OACTIVE;
|
rt2560_start(sc);
|
||||||
if ((sc->sc_flags &
|
|
||||||
(RT2560_F_DATA_OACTIVE | RT2560_F_PRIO_OACTIVE)) == 0)
|
|
||||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
|
||||||
rt2560_start_locked(ifp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1116,8 +1092,7 @@ rt2560_prio_intr(struct rt2560_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2560_decryption_intr(struct rt2560_softc *sc)
|
rt2560_decryption_intr(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
struct rt2560_rx_desc *desc;
|
struct rt2560_rx_desc *desc;
|
||||||
struct rt2560_rx_data *data;
|
struct rt2560_rx_data *data;
|
||||||
bus_addr_t physaddr;
|
bus_addr_t physaddr;
|
||||||
@@ -1127,7 +1102,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
|
|||||||
int hw, error;
|
int hw, error;
|
||||||
int8_t rssi, nf;
|
int8_t rssi, nf;
|
||||||
|
|
||||||
/* retrieve last decriptor index processed by cipher engine */
|
/* retrieve last descriptor index processed by cipher engine */
|
||||||
hw = RAL_READ(sc, RT2560_SECCSR0) - sc->rxq.physaddr;
|
hw = RAL_READ(sc, RT2560_SECCSR0) - sc->rxq.physaddr;
|
||||||
hw /= RT2560_RX_DESC_SIZE;
|
hw /= RT2560_RX_DESC_SIZE;
|
||||||
|
|
||||||
@@ -1143,13 +1118,13 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (data->drop) {
|
if (data->drop) {
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((le32toh(desc->flags) & RT2560_RX_CIPHER_MASK) != 0 &&
|
if ((le32toh(desc->flags) & RT2560_RX_CIPHER_MASK) != 0 &&
|
||||||
(le32toh(desc->flags) & RT2560_RX_ICV_ERROR)) {
|
(le32toh(desc->flags) & RT2560_RX_ICV_ERROR)) {
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1162,7 +1137,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
|
|||||||
*/
|
*/
|
||||||
mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
||||||
if (mnew == NULL) {
|
if (mnew == NULL) {
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1185,7 +1160,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
|
|||||||
panic("%s: could not load old rx mbuf",
|
panic("%s: could not load old rx mbuf",
|
||||||
device_get_name(sc->sc_dev));
|
device_get_name(sc->sc_dev));
|
||||||
}
|
}
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1198,7 +1173,6 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
|
|||||||
desc->physaddr = htole32(physaddr);
|
desc->physaddr = htole32(physaddr);
|
||||||
|
|
||||||
/* finalize mbuf */
|
/* finalize mbuf */
|
||||||
m->m_pkthdr.rcvif = ifp;
|
|
||||||
m->m_pkthdr.len = m->m_len =
|
m->m_pkthdr.len = m->m_len =
|
||||||
(le32toh(desc->flags) >> 16) & 0xfff;
|
(le32toh(desc->flags) >> 16) & 0xfff;
|
||||||
|
|
||||||
@@ -1305,8 +1279,7 @@ rt2560_rx_intr(struct rt2560_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2560_beacon_update(struct ieee80211vap *vap, int item)
|
rt2560_beacon_update(struct ieee80211vap *vap, int item)
|
||||||
{
|
{
|
||||||
struct rt2560_vap *rvp = RT2560_VAP(vap);
|
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
|
||||||
struct ieee80211_beacon_offsets *bo = &rvp->ral_bo;
|
|
||||||
|
|
||||||
setbit(bo->bo_flags, item);
|
setbit(bo->bo_flags, item);
|
||||||
}
|
}
|
||||||
@@ -1318,10 +1291,7 @@ rt2560_beacon_update(struct ieee80211vap *vap, int item)
|
|||||||
static void
|
static void
|
||||||
rt2560_beacon_expire(struct rt2560_softc *sc)
|
rt2560_beacon_expire(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
|
||||||
struct rt2560_vap *rvp = RT2560_VAP(vap);
|
|
||||||
struct rt2560_tx_data *data;
|
struct rt2560_tx_data *data;
|
||||||
|
|
||||||
if (ic->ic_opmode != IEEE80211_M_IBSS &&
|
if (ic->ic_opmode != IEEE80211_M_IBSS &&
|
||||||
@@ -1340,7 +1310,7 @@ rt2560_beacon_expire(struct rt2560_softc *sc)
|
|||||||
bus_dmamap_unload(sc->bcnq.data_dmat, data->map);
|
bus_dmamap_unload(sc->bcnq.data_dmat, data->map);
|
||||||
|
|
||||||
/* XXX 1 =>'s mcast frames which means all PS sta's will wakeup! */
|
/* XXX 1 =>'s mcast frames which means all PS sta's will wakeup! */
|
||||||
ieee80211_beacon_update(data->ni, &rvp->ral_bo, data->m, 1);
|
ieee80211_beacon_update(data->ni, data->m, 1);
|
||||||
|
|
||||||
rt2560_tx_bcn(sc, data->m, data->ni);
|
rt2560_tx_bcn(sc, data->m, data->ni);
|
||||||
|
|
||||||
@@ -1360,7 +1330,6 @@ void
|
|||||||
rt2560_intr(void *arg)
|
rt2560_intr(void *arg)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = arg;
|
struct rt2560_softc *sc = arg;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
uint32_t r;
|
uint32_t r;
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
@@ -1370,7 +1339,7 @@ rt2560_intr(void *arg)
|
|||||||
RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
|
RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
|
||||||
|
|
||||||
/* don't re-enable interrupts if we're shutting down */
|
/* don't re-enable interrupts if we're shutting down */
|
||||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
if (!(sc->sc_flags & RT2560_F_RUNNING)) {
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1439,8 +1408,7 @@ static void
|
|||||||
rt2560_setup_tx_desc(struct rt2560_softc *sc, struct rt2560_tx_desc *desc,
|
rt2560_setup_tx_desc(struct rt2560_softc *sc, struct rt2560_tx_desc *desc,
|
||||||
uint32_t flags, int len, int rate, int encrypt, bus_addr_t physaddr)
|
uint32_t flags, int len, int rate, int encrypt, bus_addr_t physaddr)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint16_t plcp_length;
|
uint16_t plcp_length;
|
||||||
int remainder;
|
int remainder;
|
||||||
|
|
||||||
@@ -1465,7 +1433,7 @@ rt2560_setup_tx_desc(struct rt2560_softc *sc, struct rt2560_tx_desc *desc,
|
|||||||
desc->plcp_length_hi = plcp_length >> 6;
|
desc->plcp_length_hi = plcp_length >> 6;
|
||||||
desc->plcp_length_lo = plcp_length & 0x3f;
|
desc->plcp_length_lo = plcp_length & 0x3f;
|
||||||
} else {
|
} else {
|
||||||
plcp_length = (16 * len + rate - 1) / rate;
|
plcp_length = howmany(16 * len, rate);
|
||||||
if (rate == 22) {
|
if (rate == 22) {
|
||||||
remainder = (16 * len) % 22;
|
remainder = (16 * len) % 22;
|
||||||
if (remainder != 0 && remainder < 7)
|
if (remainder != 0 && remainder < 7)
|
||||||
@@ -1559,7 +1527,7 @@ rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0,
|
|||||||
|
|
||||||
wh = mtod(m0, struct ieee80211_frame *);
|
wh = mtod(m0, struct ieee80211_frame *);
|
||||||
|
|
||||||
if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
||||||
k = ieee80211_crypto_encap(ni, m0);
|
k = ieee80211_crypto_encap(ni, m0);
|
||||||
if (k == NULL) {
|
if (k == NULL) {
|
||||||
m_freem(m0);
|
m_freem(m0);
|
||||||
@@ -1805,7 +1773,7 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0,
|
|||||||
rate = ni->ni_txrate;
|
rate = ni->ni_txrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
||||||
k = ieee80211_crypto_encap(ni, m0);
|
k = ieee80211_crypto_encap(ni, m0);
|
||||||
if (k == NULL) {
|
if (k == NULL) {
|
||||||
m_freem(m0);
|
m_freem(m0);
|
||||||
@@ -1915,55 +1883,57 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
rt2560_start_locked(struct ifnet *ifp)
|
rt2560_transmit(struct ieee80211com *ic, struct mbuf *m)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct mbuf *m;
|
int error;
|
||||||
struct ieee80211_node *ni;
|
|
||||||
|
|
||||||
RAL_LOCK_ASSERT(sc);
|
RAL_LOCK(sc);
|
||||||
|
if ((sc->sc_flags & RT2560_F_RUNNING) == 0) {
|
||||||
for (;;) {
|
RAL_UNLOCK(sc);
|
||||||
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
|
return (ENXIO);
|
||||||
if (m == NULL)
|
|
||||||
break;
|
|
||||||
if (sc->txq.queued >= RT2560_TX_RING_COUNT - 1) {
|
|
||||||
IFQ_DRV_PREPEND(&ifp->if_snd, m);
|
|
||||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
|
||||||
sc->sc_flags |= RT2560_F_DATA_OACTIVE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
|
|
||||||
if (rt2560_tx_data(sc, m, ni) != 0) {
|
|
||||||
ieee80211_free_node(ni);
|
|
||||||
ifp->if_oerrors++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
sc->sc_tx_timer = 5;
|
|
||||||
}
|
}
|
||||||
|
error = mbufq_enqueue(&sc->sc_snd, m);
|
||||||
|
if (error) {
|
||||||
|
RAL_UNLOCK(sc);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
rt2560_start(sc);
|
||||||
|
RAL_UNLOCK(sc);
|
||||||
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_start(struct ifnet *ifp)
|
rt2560_start(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
struct ieee80211_node *ni;
|
||||||
|
struct mbuf *m;
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK_ASSERT(sc);
|
||||||
rt2560_start_locked(ifp);
|
|
||||||
RAL_UNLOCK(sc);
|
while (sc->txq.queued < RT2560_TX_RING_COUNT - 1 &&
|
||||||
|
(m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
|
||||||
|
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
|
||||||
|
if (rt2560_tx_data(sc, m, ni) != 0) {
|
||||||
|
if_inc_counter(ni->ni_vap->iv_ifp,
|
||||||
|
IFCOUNTER_OERRORS, 1);
|
||||||
|
ieee80211_free_node(ni);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sc->sc_tx_timer = 5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_watchdog(void *arg)
|
rt2560_watchdog(void *arg)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = arg;
|
struct rt2560_softc *sc = arg;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
|
|
||||||
RAL_LOCK_ASSERT(sc);
|
RAL_LOCK_ASSERT(sc);
|
||||||
|
|
||||||
KASSERT(ifp->if_drv_flags & IFF_DRV_RUNNING, ("not running"));
|
KASSERT(sc->sc_flags & RT2560_F_RUNNING, ("not running"));
|
||||||
|
|
||||||
if (sc->sc_invalid) /* card ejected */
|
if (sc->sc_invalid) /* card ejected */
|
||||||
return;
|
return;
|
||||||
@@ -1972,51 +1942,33 @@ rt2560_watchdog(void *arg)
|
|||||||
rt2560_tx_intr(sc);
|
rt2560_tx_intr(sc);
|
||||||
|
|
||||||
if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
|
if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
|
||||||
if_printf(ifp, "device timeout\n");
|
device_printf(sc->sc_dev, "device timeout\n");
|
||||||
rt2560_init_locked(sc);
|
rt2560_init_locked(sc);
|
||||||
ifp->if_oerrors++;
|
counter_u64_add(sc->sc_ic.ic_oerrors, 1);
|
||||||
/* NB: callout is reset in rt2560_init() */
|
/* NB: callout is reset in rt2560_init() */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
|
callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
rt2560_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
rt2560_parent(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
int startall = 0;
|
||||||
struct ifreq *ifr = (struct ifreq *) data;
|
|
||||||
int error = 0, startall = 0;
|
|
||||||
|
|
||||||
switch (cmd) {
|
RAL_LOCK(sc);
|
||||||
case SIOCSIFFLAGS:
|
if (ic->ic_nrunning > 0) {
|
||||||
RAL_LOCK(sc);
|
if ((sc->sc_flags & RT2560_F_RUNNING) == 0) {
|
||||||
if (ifp->if_flags & IFF_UP) {
|
rt2560_init_locked(sc);
|
||||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
|
startall = 1;
|
||||||
rt2560_init_locked(sc);
|
} else
|
||||||
startall = 1;
|
rt2560_update_promisc(ic);
|
||||||
} else
|
} else if (sc->sc_flags & RT2560_F_RUNNING)
|
||||||
rt2560_update_promisc(ifp);
|
rt2560_stop_locked(sc);
|
||||||
} else {
|
RAL_UNLOCK(sc);
|
||||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
if (startall)
|
||||||
rt2560_stop_locked(sc);
|
ieee80211_start_all(ic);
|
||||||
}
|
|
||||||
RAL_UNLOCK(sc);
|
|
||||||
if (startall)
|
|
||||||
ieee80211_start_all(ic);
|
|
||||||
break;
|
|
||||||
case SIOCGIFMEDIA:
|
|
||||||
error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
|
|
||||||
break;
|
|
||||||
case SIOCGIFADDR:
|
|
||||||
error = ether_ioctl(ifp, cmd, data);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error = EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2100,8 +2052,7 @@ rt2560_rf_write(struct rt2560_softc *sc, uint8_t reg, uint32_t val)
|
|||||||
static void
|
static void
|
||||||
rt2560_set_chan(struct rt2560_softc *sc, struct ieee80211_channel *c)
|
rt2560_set_chan(struct rt2560_softc *sc, struct ieee80211_channel *c)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint8_t power, tmp;
|
uint8_t power, tmp;
|
||||||
u_int i, chan;
|
u_int i, chan;
|
||||||
|
|
||||||
@@ -2197,11 +2148,30 @@ rt2560_set_chan(struct rt2560_softc *sc, struct ieee80211_channel *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rt2560_getradiocaps(struct ieee80211com *ic,
|
||||||
|
int maxchans, int *nchans, struct ieee80211_channel chans[])
|
||||||
|
{
|
||||||
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
|
uint8_t bands[IEEE80211_MODE_BYTES];
|
||||||
|
|
||||||
|
memset(bands, 0, sizeof(bands));
|
||||||
|
setbit(bands, IEEE80211_MODE_11B);
|
||||||
|
setbit(bands, IEEE80211_MODE_11G);
|
||||||
|
ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
|
||||||
|
rt2560_chan_2ghz, nitems(rt2560_chan_2ghz), bands, 0);
|
||||||
|
|
||||||
|
if (sc->rf_rev == RT2560_RF_5222) {
|
||||||
|
setbit(bands, IEEE80211_MODE_11A);
|
||||||
|
ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
|
||||||
|
rt2560_chan_5ghz, nitems(rt2560_chan_5ghz), bands, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_set_channel(struct ieee80211com *ic)
|
rt2560_set_channel(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
rt2560_set_chan(sc, ic->ic_curchan);
|
rt2560_set_chan(sc, ic->ic_curchan);
|
||||||
@@ -2237,8 +2207,7 @@ rt2560_disable_rf_tune(struct rt2560_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2560_enable_tsf_sync(struct rt2560_softc *sc)
|
rt2560_enable_tsf_sync(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
||||||
uint16_t logcwmin, preload;
|
uint16_t logcwmin, preload;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
@@ -2279,8 +2248,7 @@ rt2560_enable_tsf(struct rt2560_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2560_update_plcp(struct rt2560_softc *sc)
|
rt2560_update_plcp(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
|
|
||||||
/* no short preamble for 1Mbps */
|
/* no short preamble for 1Mbps */
|
||||||
RAL_WRITE(sc, RT2560_PLCP1MCSR, 0x00700400);
|
RAL_WRITE(sc, RT2560_PLCP1MCSR, 0x00700400);
|
||||||
@@ -2306,16 +2274,15 @@ rt2560_update_plcp(struct rt2560_softc *sc)
|
|||||||
* IEEE Std 802.11-1999 pp. 85 to know how these values are computed.
|
* IEEE Std 802.11-1999 pp. 85 to know how these values are computed.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rt2560_update_slot(struct ifnet *ifp)
|
rt2560_update_slot(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint8_t slottime;
|
uint8_t slottime;
|
||||||
uint16_t tx_sifs, tx_pifs, tx_difs, eifs;
|
uint16_t tx_sifs, tx_pifs, tx_difs, eifs;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
#ifndef FORCE_SLOTTIME
|
#ifndef FORCE_SLOTTIME
|
||||||
slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
|
slottime = IEEE80211_GET_SLOTTIME(ic);
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* Setting slot time according to "short slot time" capability
|
* Setting slot time according to "short slot time" capability
|
||||||
@@ -2333,13 +2300,13 @@ rt2560_update_slot(struct ifnet *ifp)
|
|||||||
* (-1Mb~-2Mb lower) and the _whole_ BSS would stop using short
|
* (-1Mb~-2Mb lower) and the _whole_ BSS would stop using short
|
||||||
* slot time.
|
* slot time.
|
||||||
*/
|
*/
|
||||||
slottime = 20;
|
slottime = IEEE80211_DUR_SLOT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* update the MAC slot boundaries */
|
/* update the MAC slot boundaries */
|
||||||
tx_sifs = RAL_SIFS - RT2560_TXRX_TURNAROUND;
|
tx_sifs = RAL_SIFS - RT2560_TXRX_TURNAROUND;
|
||||||
tx_pifs = tx_sifs + slottime;
|
tx_pifs = tx_sifs + slottime;
|
||||||
tx_difs = tx_sifs + 2 * slottime;
|
tx_difs = IEEE80211_DUR_DIFS(tx_sifs, slottime);
|
||||||
eifs = (ic->ic_curmode == IEEE80211_MODE_11B) ? 364 : 60;
|
eifs = (ic->ic_curmode == IEEE80211_MODE_11B) ? 364 : 60;
|
||||||
|
|
||||||
tmp = RAL_READ(sc, RT2560_CSR11);
|
tmp = RAL_READ(sc, RT2560_CSR11);
|
||||||
@@ -2359,9 +2326,7 @@ static void
|
|||||||
rt2560_set_basicrates(struct rt2560_softc *sc,
|
rt2560_set_basicrates(struct rt2560_softc *sc,
|
||||||
const struct ieee80211_rateset *rs)
|
const struct ieee80211_rateset *rs)
|
||||||
{
|
{
|
||||||
#define RV(r) ((r) & IEEE80211_RATE_VAL)
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint32_t mask = 0;
|
uint32_t mask = 0;
|
||||||
uint8_t rate;
|
uint8_t rate;
|
||||||
int i;
|
int i;
|
||||||
@@ -2372,13 +2337,13 @@ rt2560_set_basicrates(struct rt2560_softc *sc,
|
|||||||
if (!(rate & IEEE80211_RATE_BASIC))
|
if (!(rate & IEEE80211_RATE_BASIC))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mask |= 1 << ic->ic_rt->rateCodeToIndex[RV(rate)];
|
mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt,
|
||||||
|
IEEE80211_RV(rate));
|
||||||
}
|
}
|
||||||
|
|
||||||
RAL_WRITE(sc, RT2560_ARSP_PLCP_1, mask);
|
RAL_WRITE(sc, RT2560_ARSP_PLCP_1, mask);
|
||||||
|
|
||||||
DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask);
|
DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask);
|
||||||
#undef RV
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2406,7 +2371,7 @@ rt2560_set_bssid(struct rt2560_softc *sc, const uint8_t *bssid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_set_macaddr(struct rt2560_softc *sc, uint8_t *addr)
|
rt2560_set_macaddr(struct rt2560_softc *sc, const uint8_t *addr)
|
||||||
{
|
{
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
@@ -2436,21 +2401,21 @@ rt2560_get_macaddr(struct rt2560_softc *sc, uint8_t *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_update_promisc(struct ifnet *ifp)
|
rt2560_update_promisc(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
tmp = RAL_READ(sc, RT2560_RXCSR0);
|
tmp = RAL_READ(sc, RT2560_RXCSR0);
|
||||||
|
|
||||||
tmp &= ~RT2560_DROP_NOT_TO_ME;
|
tmp &= ~RT2560_DROP_NOT_TO_ME;
|
||||||
if (!(ifp->if_flags & IFF_PROMISC))
|
if (ic->ic_promisc == 0)
|
||||||
tmp |= RT2560_DROP_NOT_TO_ME;
|
tmp |= RT2560_DROP_NOT_TO_ME;
|
||||||
|
|
||||||
RAL_WRITE(sc, RT2560_RXCSR0, tmp);
|
RAL_WRITE(sc, RT2560_RXCSR0, tmp);
|
||||||
|
|
||||||
DPRINTF(sc, "%s promiscuous mode\n", (ifp->if_flags & IFF_PROMISC) ?
|
DPRINTF(sc, "%s promiscuous mode\n",
|
||||||
"entering" : "leaving");
|
(ic->ic_promisc > 0) ? "entering" : "leaving");
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -2516,19 +2481,17 @@ rt2560_read_config(struct rt2560_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2560_scan_start(struct ieee80211com *ic)
|
rt2560_scan_start(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
|
||||||
|
|
||||||
/* abort TSF synchronization */
|
/* abort TSF synchronization */
|
||||||
RAL_WRITE(sc, RT2560_CSR14, 0);
|
RAL_WRITE(sc, RT2560_CSR14, 0);
|
||||||
rt2560_set_bssid(sc, ifp->if_broadcastaddr);
|
rt2560_set_bssid(sc, ieee80211broadcastaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_scan_end(struct ieee80211com *ic)
|
rt2560_scan_end(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
|
||||||
struct ieee80211vap *vap = ic->ic_scan->ss_vap;
|
struct ieee80211vap *vap = ic->ic_scan->ss_vap;
|
||||||
|
|
||||||
rt2560_enable_tsf_sync(sc);
|
rt2560_enable_tsf_sync(sc);
|
||||||
@@ -2539,7 +2502,6 @@ rt2560_scan_end(struct ieee80211com *ic)
|
|||||||
static int
|
static int
|
||||||
rt2560_bbp_init(struct rt2560_softc *sc)
|
rt2560_bbp_init(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
#define N(a) (sizeof (a) / sizeof ((a)[0]))
|
|
||||||
int i, ntries;
|
int i, ntries;
|
||||||
|
|
||||||
/* wait for BBP to be ready */
|
/* wait for BBP to be ready */
|
||||||
@@ -2554,7 +2516,7 @@ rt2560_bbp_init(struct rt2560_softc *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* initialize BBP registers to default values */
|
/* initialize BBP registers to default values */
|
||||||
for (i = 0; i < N(rt2560_def_bbp); i++) {
|
for (i = 0; i < nitems(rt2560_def_bbp); i++) {
|
||||||
rt2560_bbp_write(sc, rt2560_def_bbp[i].reg,
|
rt2560_bbp_write(sc, rt2560_def_bbp[i].reg,
|
||||||
rt2560_def_bbp[i].val);
|
rt2560_def_bbp[i].val);
|
||||||
}
|
}
|
||||||
@@ -2568,7 +2530,6 @@ rt2560_bbp_init(struct rt2560_softc *sc)
|
|||||||
rt2560_bbp_write(sc, 17, 0x48); /* XXX restore bbp17 */
|
rt2560_bbp_write(sc, 17, 0x48); /* XXX restore bbp17 */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#undef N
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2621,9 +2582,8 @@ rt2560_set_rxantenna(struct rt2560_softc *sc, int antenna)
|
|||||||
static void
|
static void
|
||||||
rt2560_init_locked(struct rt2560_softc *sc)
|
rt2560_init_locked(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
#define N(a) (sizeof (a) / sizeof ((a)[0]))
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -2651,15 +2611,15 @@ rt2560_init_locked(struct rt2560_softc *sc)
|
|||||||
RAL_WRITE(sc, RT2560_RXCSR2, sc->rxq.physaddr);
|
RAL_WRITE(sc, RT2560_RXCSR2, sc->rxq.physaddr);
|
||||||
|
|
||||||
/* initialize MAC registers to default values */
|
/* initialize MAC registers to default values */
|
||||||
for (i = 0; i < N(rt2560_def_mac); i++)
|
for (i = 0; i < nitems(rt2560_def_mac); i++)
|
||||||
RAL_WRITE(sc, rt2560_def_mac[i].reg, rt2560_def_mac[i].val);
|
RAL_WRITE(sc, rt2560_def_mac[i].reg, rt2560_def_mac[i].val);
|
||||||
|
|
||||||
rt2560_set_macaddr(sc, IF_LLADDR(ifp));
|
rt2560_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr);
|
||||||
|
|
||||||
/* set basic rate set (will be updated later) */
|
/* set basic rate set (will be updated later) */
|
||||||
RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x153);
|
RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x153);
|
||||||
|
|
||||||
rt2560_update_slot(ifp);
|
rt2560_update_slot(ic);
|
||||||
rt2560_update_plcp(sc);
|
rt2560_update_plcp(sc);
|
||||||
rt2560_update_led(sc, 0, 0);
|
rt2560_update_led(sc, 0, 0);
|
||||||
|
|
||||||
@@ -2684,7 +2644,7 @@ rt2560_init_locked(struct rt2560_softc *sc)
|
|||||||
if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
|
if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
|
||||||
ic->ic_opmode != IEEE80211_M_MBSS)
|
ic->ic_opmode != IEEE80211_M_MBSS)
|
||||||
tmp |= RT2560_DROP_TODS;
|
tmp |= RT2560_DROP_TODS;
|
||||||
if (!(ifp->if_flags & IFF_PROMISC))
|
if (ic->ic_promisc == 0)
|
||||||
tmp |= RT2560_DROP_NOT_TO_ME;
|
tmp |= RT2560_DROP_NOT_TO_ME;
|
||||||
}
|
}
|
||||||
RAL_WRITE(sc, RT2560_RXCSR0, tmp);
|
RAL_WRITE(sc, RT2560_RXCSR0, tmp);
|
||||||
@@ -2699,32 +2659,28 @@ rt2560_init_locked(struct rt2560_softc *sc)
|
|||||||
/* enable interrupts */
|
/* enable interrupts */
|
||||||
RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
|
RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
|
||||||
|
|
||||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
sc->sc_flags |= RT2560_F_RUNNING;
|
||||||
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
|
||||||
|
|
||||||
callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
|
callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
|
||||||
#undef N
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_init(void *priv)
|
rt2560_init(void *priv)
|
||||||
{
|
{
|
||||||
struct rt2560_softc *sc = priv;
|
struct rt2560_softc *sc = priv;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
rt2560_init_locked(sc);
|
rt2560_init_locked(sc);
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
|
|
||||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
if (sc->sc_flags & RT2560_F_RUNNING)
|
||||||
ieee80211_start_all(ic); /* start all vap's */
|
ieee80211_start_all(ic); /* start all vap's */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2560_stop_locked(struct rt2560_softc *sc)
|
rt2560_stop_locked(struct rt2560_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
volatile int *flags = &sc->sc_flags;
|
volatile int *flags = &sc->sc_flags;
|
||||||
|
|
||||||
RAL_LOCK_ASSERT(sc);
|
RAL_LOCK_ASSERT(sc);
|
||||||
@@ -2735,8 +2691,8 @@ rt2560_stop_locked(struct rt2560_softc *sc)
|
|||||||
callout_stop(&sc->watchdog_ch);
|
callout_stop(&sc->watchdog_ch);
|
||||||
sc->sc_tx_timer = 0;
|
sc->sc_tx_timer = 0;
|
||||||
|
|
||||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
if (sc->sc_flags & RT2560_F_RUNNING) {
|
||||||
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
sc->sc_flags &= ~RT2560_F_RUNNING;
|
||||||
|
|
||||||
/* abort Tx */
|
/* abort Tx */
|
||||||
RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX);
|
RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX);
|
||||||
@@ -2758,7 +2714,6 @@ rt2560_stop_locked(struct rt2560_softc *sc)
|
|||||||
rt2560_reset_tx_ring(sc, &sc->bcnq);
|
rt2560_reset_tx_ring(sc, &sc->bcnq);
|
||||||
rt2560_reset_rx_ring(sc, &sc->rxq);
|
rt2560_reset_rx_ring(sc, &sc->rxq);
|
||||||
}
|
}
|
||||||
sc->sc_flags &= ~(RT2560_F_PRIO_OACTIVE | RT2560_F_DATA_OACTIVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2776,29 +2731,22 @@ rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
|||||||
const struct ieee80211_bpf_params *params)
|
const struct ieee80211_bpf_params *params)
|
||||||
{
|
{
|
||||||
struct ieee80211com *ic = ni->ni_ic;
|
struct ieee80211com *ic = ni->ni_ic;
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2560_softc *sc = ic->ic_softc;
|
||||||
struct rt2560_softc *sc = ifp->if_softc;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
|
|
||||||
/* prevent management frames from being sent if we're not ready */
|
/* prevent management frames from being sent if we're not ready */
|
||||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
if (!(sc->sc_flags & RT2560_F_RUNNING)) {
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
ieee80211_free_node(ni);
|
|
||||||
return ENETDOWN;
|
return ENETDOWN;
|
||||||
}
|
}
|
||||||
if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) {
|
if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) {
|
||||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
|
||||||
sc->sc_flags |= RT2560_F_PRIO_OACTIVE;
|
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
ieee80211_free_node(ni);
|
|
||||||
return ENOBUFS; /* XXX */
|
return ENOBUFS; /* XXX */
|
||||||
}
|
}
|
||||||
|
|
||||||
ifp->if_opackets++;
|
|
||||||
|
|
||||||
if (params == NULL) {
|
if (params == NULL) {
|
||||||
/*
|
/*
|
||||||
* Legacy path; interpret frame contents to decide
|
* Legacy path; interpret frame contents to decide
|
||||||
@@ -2820,8 +2768,6 @@ rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
bad:
|
bad:
|
||||||
ifp->if_oerrors++;
|
|
||||||
ieee80211_free_node(ni);
|
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
return EIO; /* XXX */
|
return EIO; /* XXX */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2560reg.h 258780 2013-11-30 22:17:27Z eadler $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005, 2006
|
* Copyright (c) 2005, 2006
|
||||||
@@ -268,7 +268,7 @@ struct rt2560_rx_desc {
|
|||||||
#define RT2560_BBP_BUSY (1 << 15)
|
#define RT2560_BBP_BUSY (1 << 15)
|
||||||
#define RT2560_BBP_WRITE (1 << 16)
|
#define RT2560_BBP_WRITE (1 << 16)
|
||||||
#define RT2560_RF_20BIT (20 << 24)
|
#define RT2560_RF_20BIT (20 << 24)
|
||||||
#define RT2560_RF_BUSY (1 << 31)
|
#define RT2560_RF_BUSY (1U << 31)
|
||||||
|
|
||||||
#define RT2560_RF_2522 0x00
|
#define RT2560_RF_2522 0x00
|
||||||
#define RT2560_RF_2523 0x01
|
#define RT2560_RF_2523 0x01
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2560var.h 289168 2015-10-12 05:21:51Z adrian $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005, 2006
|
* Copyright (c) 2005, 2006
|
||||||
@@ -97,7 +97,6 @@ struct rt2560_rx_ring {
|
|||||||
|
|
||||||
struct rt2560_vap {
|
struct rt2560_vap {
|
||||||
struct ieee80211vap ral_vap;
|
struct ieee80211vap ral_vap;
|
||||||
struct ieee80211_beacon_offsets ral_bo;
|
|
||||||
|
|
||||||
int (*ral_newstate)(struct ieee80211vap *,
|
int (*ral_newstate)(struct ieee80211vap *,
|
||||||
enum ieee80211_state, int);
|
enum ieee80211_state, int);
|
||||||
@@ -105,13 +104,13 @@ struct rt2560_vap {
|
|||||||
#define RT2560_VAP(vap) ((struct rt2560_vap *)(vap))
|
#define RT2560_VAP(vap) ((struct rt2560_vap *)(vap))
|
||||||
|
|
||||||
struct rt2560_softc {
|
struct rt2560_softc {
|
||||||
struct ifnet *sc_ifp;
|
struct ieee80211com sc_ic;
|
||||||
|
struct mtx sc_mtx;
|
||||||
|
struct mbufq sc_snd;
|
||||||
device_t sc_dev;
|
device_t sc_dev;
|
||||||
bus_space_tag_t sc_st;
|
bus_space_tag_t sc_st;
|
||||||
bus_space_handle_t sc_sh;
|
bus_space_handle_t sc_sh;
|
||||||
|
|
||||||
struct mtx sc_mtx;
|
|
||||||
|
|
||||||
struct callout watchdog_ch;
|
struct callout watchdog_ch;
|
||||||
|
|
||||||
int sc_tx_timer;
|
int sc_tx_timer;
|
||||||
@@ -147,13 +146,10 @@ struct rt2560_softc {
|
|||||||
int nb_ant;
|
int nb_ant;
|
||||||
|
|
||||||
struct rt2560_rx_radiotap_header sc_rxtap;
|
struct rt2560_rx_radiotap_header sc_rxtap;
|
||||||
int sc_rxtap_len;
|
|
||||||
|
|
||||||
struct rt2560_tx_radiotap_header sc_txtap;
|
struct rt2560_tx_radiotap_header sc_txtap;
|
||||||
int sc_txtap_len;
|
|
||||||
#define RT2560_F_INPUT_RUNNING 0x1
|
#define RT2560_F_INPUT_RUNNING 0x1
|
||||||
#define RT2560_F_PRIO_OACTIVE 0x2
|
#define RT2560_F_RUNNING 0x2
|
||||||
#define RT2560_F_DATA_OACTIVE 0x4
|
|
||||||
int sc_flags;
|
int sc_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2661.c 314222 2017-02-24 21:19:40Z avos $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006
|
* Copyright (c) 2006
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/rt2661.c 314222 2017-02-24 21:19:40Z avos $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Ralink Technology RT2561, RT2561S and RT2661 chipset driver
|
* Ralink Technology RT2561, RT2561S and RT2661 chipset driver
|
||||||
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <net/if_var.h>
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
#include <net/if_dl.h>
|
#include <net/if_dl.h>
|
||||||
@@ -112,6 +113,8 @@ static void rt2661_mcu_wakeup(struct rt2661_softc *);
|
|||||||
static void rt2661_mcu_cmd_intr(struct rt2661_softc *);
|
static void rt2661_mcu_cmd_intr(struct rt2661_softc *);
|
||||||
static void rt2661_scan_start(struct ieee80211com *);
|
static void rt2661_scan_start(struct ieee80211com *);
|
||||||
static void rt2661_scan_end(struct ieee80211com *);
|
static void rt2661_scan_end(struct ieee80211com *);
|
||||||
|
static void rt2661_getradiocaps(struct ieee80211com *, int, int *,
|
||||||
|
struct ieee80211_channel[]);
|
||||||
static void rt2661_set_channel(struct ieee80211com *);
|
static void rt2661_set_channel(struct ieee80211com *);
|
||||||
static void rt2661_setup_tx_desc(struct rt2661_softc *,
|
static void rt2661_setup_tx_desc(struct rt2661_softc *,
|
||||||
struct rt2661_tx_desc *, uint32_t, uint16_t, int,
|
struct rt2661_tx_desc *, uint32_t, uint16_t, int,
|
||||||
@@ -120,12 +123,12 @@ static int rt2661_tx_data(struct rt2661_softc *, struct mbuf *,
|
|||||||
struct ieee80211_node *, int);
|
struct ieee80211_node *, int);
|
||||||
static int rt2661_tx_mgt(struct rt2661_softc *, struct mbuf *,
|
static int rt2661_tx_mgt(struct rt2661_softc *, struct mbuf *,
|
||||||
struct ieee80211_node *);
|
struct ieee80211_node *);
|
||||||
static void rt2661_start_locked(struct ifnet *);
|
static int rt2661_transmit(struct ieee80211com *, struct mbuf *);
|
||||||
static void rt2661_start(struct ifnet *);
|
static void rt2661_start(struct rt2661_softc *);
|
||||||
static int rt2661_raw_xmit(struct ieee80211_node *, struct mbuf *,
|
static int rt2661_raw_xmit(struct ieee80211_node *, struct mbuf *,
|
||||||
const struct ieee80211_bpf_params *);
|
const struct ieee80211_bpf_params *);
|
||||||
static void rt2661_watchdog(void *);
|
static void rt2661_watchdog(void *);
|
||||||
static int rt2661_ioctl(struct ifnet *, u_long, caddr_t);
|
static void rt2661_parent(struct ieee80211com *);
|
||||||
static void rt2661_bbp_write(struct rt2661_softc *, uint8_t,
|
static void rt2661_bbp_write(struct rt2661_softc *, uint8_t,
|
||||||
uint8_t);
|
uint8_t);
|
||||||
static uint8_t rt2661_bbp_read(struct rt2661_softc *, uint8_t);
|
static uint8_t rt2661_bbp_read(struct rt2661_softc *, uint8_t);
|
||||||
@@ -146,9 +149,9 @@ static void rt2661_set_bssid(struct rt2661_softc *,
|
|||||||
const uint8_t *);
|
const uint8_t *);
|
||||||
static void rt2661_set_macaddr(struct rt2661_softc *,
|
static void rt2661_set_macaddr(struct rt2661_softc *,
|
||||||
const uint8_t *);
|
const uint8_t *);
|
||||||
static void rt2661_update_promisc(struct ifnet *);
|
static void rt2661_update_promisc(struct ieee80211com *);
|
||||||
static int rt2661_wme_update(struct ieee80211com *) __unused;
|
static int rt2661_wme_update(struct ieee80211com *) __unused;
|
||||||
static void rt2661_update_slot(struct ifnet *);
|
static void rt2661_update_slot(struct ieee80211com *);
|
||||||
static const char *rt2661_get_rf(int);
|
static const char *rt2661_get_rf(int);
|
||||||
static void rt2661_read_eeprom(struct rt2661_softc *,
|
static void rt2661_read_eeprom(struct rt2661_softc *,
|
||||||
uint8_t macaddr[IEEE80211_ADDR_LEN]);
|
uint8_t macaddr[IEEE80211_ADDR_LEN]);
|
||||||
@@ -192,31 +195,29 @@ static const struct rfprog {
|
|||||||
RT2661_RF5225_2
|
RT2661_RF5225_2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const uint8_t rt2661_chan_2ghz[] =
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
|
||||||
|
static const uint8_t rt2661_chan_5ghz[] =
|
||||||
|
{ 36, 40, 44, 48, 52, 56, 60, 64,
|
||||||
|
100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
|
||||||
|
149, 153, 157, 161, 165 };
|
||||||
|
|
||||||
int
|
int
|
||||||
rt2661_attach(device_t dev, int id)
|
rt2661_attach(device_t dev, int id)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = device_get_softc(dev);
|
struct rt2661_softc *sc = device_get_softc(dev);
|
||||||
struct ieee80211com *ic;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ifnet *ifp;
|
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
int error, ac, ntries;
|
int error, ac, ntries;
|
||||||
uint8_t bands;
|
|
||||||
uint8_t macaddr[IEEE80211_ADDR_LEN];
|
|
||||||
|
|
||||||
sc->sc_id = id;
|
sc->sc_id = id;
|
||||||
sc->sc_dev = dev;
|
sc->sc_dev = dev;
|
||||||
|
|
||||||
ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
|
|
||||||
if (ifp == NULL) {
|
|
||||||
device_printf(sc->sc_dev, "can not if_alloc()\n");
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
ic = ifp->if_l2com;
|
|
||||||
|
|
||||||
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
|
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
|
||||||
MTX_DEF | MTX_RECURSE);
|
MTX_DEF | MTX_RECURSE);
|
||||||
|
|
||||||
callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
|
callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
|
||||||
|
mbufq_init(&sc->sc_snd, ifqmaxlen);
|
||||||
|
|
||||||
/* wait for NIC to initialize */
|
/* wait for NIC to initialize */
|
||||||
for (ntries = 0; ntries < 1000; ntries++) {
|
for (ntries = 0; ntries < 1000; ntries++) {
|
||||||
@@ -232,7 +233,7 @@ rt2661_attach(device_t dev, int id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve RF rev. no and various other things from EEPROM */
|
/* retrieve RF rev. no and various other things from EEPROM */
|
||||||
rt2661_read_eeprom(sc, macaddr);
|
rt2661_read_eeprom(sc, ic->ic_macaddr);
|
||||||
|
|
||||||
device_printf(dev, "MAC/BBP RT%X, RF %s\n", val,
|
device_printf(dev, "MAC/BBP RT%X, RF %s\n", val,
|
||||||
rt2661_get_rf(sc->rf_rev));
|
rt2661_get_rf(sc->rf_rev));
|
||||||
@@ -262,17 +263,8 @@ rt2661_attach(device_t dev, int id)
|
|||||||
goto fail3;
|
goto fail3;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifp->if_softc = sc;
|
ic->ic_softc = sc;
|
||||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
ic->ic_name = device_get_nameunit(dev);
|
||||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
|
||||||
ifp->if_init = rt2661_init;
|
|
||||||
ifp->if_ioctl = rt2661_ioctl;
|
|
||||||
ifp->if_start = rt2661_start;
|
|
||||||
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
|
|
||||||
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
|
|
||||||
IFQ_SET_READY(&ifp->if_snd);
|
|
||||||
|
|
||||||
ic->ic_ifp = ifp;
|
|
||||||
ic->ic_opmode = IEEE80211_M_STA;
|
ic->ic_opmode = IEEE80211_M_STA;
|
||||||
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
|
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
|
||||||
|
|
||||||
@@ -295,24 +287,22 @@ rt2661_attach(device_t dev, int id)
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
bands = 0;
|
rt2661_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
|
||||||
setbit(&bands, IEEE80211_MODE_11B);
|
ic->ic_channels);
|
||||||
setbit(&bands, IEEE80211_MODE_11G);
|
|
||||||
if (sc->rf_rev == RT2661_RF_5225 || sc->rf_rev == RT2661_RF_5325)
|
|
||||||
setbit(&bands, IEEE80211_MODE_11A);
|
|
||||||
ieee80211_init_channels(ic, NULL, &bands);
|
|
||||||
|
|
||||||
ieee80211_ifattach(ic, macaddr);
|
ieee80211_ifattach(ic);
|
||||||
#if 0
|
#if 0
|
||||||
ic->ic_wme.wme_update = rt2661_wme_update;
|
ic->ic_wme.wme_update = rt2661_wme_update;
|
||||||
#endif
|
#endif
|
||||||
ic->ic_scan_start = rt2661_scan_start;
|
ic->ic_scan_start = rt2661_scan_start;
|
||||||
ic->ic_scan_end = rt2661_scan_end;
|
ic->ic_scan_end = rt2661_scan_end;
|
||||||
|
ic->ic_getradiocaps = rt2661_getradiocaps;
|
||||||
ic->ic_set_channel = rt2661_set_channel;
|
ic->ic_set_channel = rt2661_set_channel;
|
||||||
ic->ic_updateslot = rt2661_update_slot;
|
ic->ic_updateslot = rt2661_update_slot;
|
||||||
ic->ic_update_promisc = rt2661_update_promisc;
|
ic->ic_update_promisc = rt2661_update_promisc;
|
||||||
ic->ic_raw_xmit = rt2661_raw_xmit;
|
ic->ic_raw_xmit = rt2661_raw_xmit;
|
||||||
|
ic->ic_transmit = rt2661_transmit;
|
||||||
|
ic->ic_parent = rt2661_parent;
|
||||||
ic->ic_vap_create = rt2661_vap_create;
|
ic->ic_vap_create = rt2661_vap_create;
|
||||||
ic->ic_vap_delete = rt2661_vap_delete;
|
ic->ic_vap_delete = rt2661_vap_delete;
|
||||||
|
|
||||||
@@ -336,7 +326,6 @@ fail3: rt2661_free_tx_ring(sc, &sc->mgtq);
|
|||||||
fail2: while (--ac >= 0)
|
fail2: while (--ac >= 0)
|
||||||
rt2661_free_tx_ring(sc, &sc->txq[ac]);
|
rt2661_free_tx_ring(sc, &sc->txq[ac]);
|
||||||
fail1: mtx_destroy(&sc->sc_mtx);
|
fail1: mtx_destroy(&sc->sc_mtx);
|
||||||
if_free(ifp);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,14 +333,14 @@ int
|
|||||||
rt2661_detach(void *xsc)
|
rt2661_detach(void *xsc)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = xsc;
|
struct rt2661_softc *sc = xsc;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
rt2661_stop_locked(sc);
|
rt2661_stop_locked(sc);
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
|
|
||||||
ieee80211_ifdetach(ic);
|
ieee80211_ifdetach(ic);
|
||||||
|
mbufq_drain(&sc->sc_snd);
|
||||||
|
|
||||||
rt2661_free_tx_ring(sc, &sc->txq[0]);
|
rt2661_free_tx_ring(sc, &sc->txq[0]);
|
||||||
rt2661_free_tx_ring(sc, &sc->txq[1]);
|
rt2661_free_tx_ring(sc, &sc->txq[1]);
|
||||||
@@ -360,8 +349,6 @@ rt2661_detach(void *xsc)
|
|||||||
rt2661_free_tx_ring(sc, &sc->mgtq);
|
rt2661_free_tx_ring(sc, &sc->mgtq);
|
||||||
rt2661_free_rx_ring(sc, &sc->rxq);
|
rt2661_free_rx_ring(sc, &sc->rxq);
|
||||||
|
|
||||||
if_free(ifp);
|
|
||||||
|
|
||||||
mtx_destroy(&sc->sc_mtx);
|
mtx_destroy(&sc->sc_mtx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -373,7 +360,7 @@ rt2661_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
const uint8_t bssid[IEEE80211_ADDR_LEN],
|
const uint8_t bssid[IEEE80211_ADDR_LEN],
|
||||||
const uint8_t mac[IEEE80211_ADDR_LEN])
|
const uint8_t mac[IEEE80211_ADDR_LEN])
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
struct rt2661_vap *rvp;
|
struct rt2661_vap *rvp;
|
||||||
struct ieee80211vap *vap;
|
struct ieee80211vap *vap;
|
||||||
|
|
||||||
@@ -386,7 +373,7 @@ rt2661_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
case IEEE80211_M_MBSS:
|
case IEEE80211_M_MBSS:
|
||||||
/* XXXRP: TBD */
|
/* XXXRP: TBD */
|
||||||
if (!TAILQ_EMPTY(&ic->ic_vaps)) {
|
if (!TAILQ_EMPTY(&ic->ic_vaps)) {
|
||||||
if_printf(ifp, "only 1 vap supported\n");
|
device_printf(sc->sc_dev, "only 1 vap supported\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (opmode == IEEE80211_M_STA)
|
if (opmode == IEEE80211_M_STA)
|
||||||
@@ -395,7 +382,8 @@ rt2661_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
case IEEE80211_M_WDS:
|
case IEEE80211_M_WDS:
|
||||||
if (TAILQ_EMPTY(&ic->ic_vaps) ||
|
if (TAILQ_EMPTY(&ic->ic_vaps) ||
|
||||||
ic->ic_opmode != IEEE80211_M_HOSTAP) {
|
ic->ic_opmode != IEEE80211_M_HOSTAP) {
|
||||||
if_printf(ifp, "wds only supported in ap mode\n");
|
device_printf(sc->sc_dev,
|
||||||
|
"wds only supported in ap mode\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -406,15 +394,12 @@ rt2661_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
flags &= ~IEEE80211_CLONE_BSSID;
|
flags &= ~IEEE80211_CLONE_BSSID;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if_printf(ifp, "unknown opmode %d\n", opmode);
|
device_printf(sc->sc_dev, "unknown opmode %d\n", opmode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rvp = (struct rt2661_vap *) malloc(sizeof(struct rt2661_vap),
|
rvp = malloc(sizeof(struct rt2661_vap), M_80211_VAP, M_WAITOK | M_ZERO);
|
||||||
M_80211_VAP, M_NOWAIT | M_ZERO);
|
|
||||||
if (rvp == NULL)
|
|
||||||
return NULL;
|
|
||||||
vap = &rvp->ral_vap;
|
vap = &rvp->ral_vap;
|
||||||
ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac);
|
ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid);
|
||||||
|
|
||||||
/* override state transition machine */
|
/* override state transition machine */
|
||||||
rvp->ral_newstate = vap->iv_newstate;
|
rvp->ral_newstate = vap->iv_newstate;
|
||||||
@@ -425,7 +410,8 @@ rt2661_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|||||||
|
|
||||||
ieee80211_ratectl_init(vap);
|
ieee80211_ratectl_init(vap);
|
||||||
/* complete setup */
|
/* complete setup */
|
||||||
ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status);
|
ieee80211_vap_attach(vap, ieee80211_media_change,
|
||||||
|
ieee80211_media_status, mac);
|
||||||
if (TAILQ_FIRST(&ic->ic_vaps) == vap)
|
if (TAILQ_FIRST(&ic->ic_vaps) == vap)
|
||||||
ic->ic_opmode = opmode;
|
ic->ic_opmode = opmode;
|
||||||
return vap;
|
return vap;
|
||||||
@@ -461,9 +447,8 @@ void
|
|||||||
rt2661_resume(void *xsc)
|
rt2661_resume(void *xsc)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = xsc;
|
struct rt2661_softc *sc = xsc;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
|
|
||||||
if (ifp->if_flags & IFF_UP)
|
if (sc->sc_ic.ic_nrunning > 0)
|
||||||
rt2661_init(sc);
|
rt2661_init(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -767,7 +752,7 @@ rt2661_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
|||||||
{
|
{
|
||||||
struct rt2661_vap *rvp = RT2661_VAP(vap);
|
struct rt2661_vap *rvp = RT2661_VAP(vap);
|
||||||
struct ieee80211com *ic = vap->iv_ic;
|
struct ieee80211com *ic = vap->iv_ic;
|
||||||
struct rt2661_softc *sc = ic->ic_ifp->if_softc;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
|
if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
|
||||||
@@ -866,11 +851,10 @@ rt2661_eeprom_read(struct rt2661_softc *sc, uint8_t addr)
|
|||||||
static void
|
static void
|
||||||
rt2661_tx_intr(struct rt2661_softc *sc)
|
rt2661_tx_intr(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
struct rt2661_tx_ring *txq;
|
struct rt2661_tx_ring *txq;
|
||||||
struct rt2661_tx_data *data;
|
struct rt2661_tx_data *data;
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
int qid, retrycnt;
|
int error, qid, retrycnt;
|
||||||
struct ieee80211vap *vap;
|
struct ieee80211vap *vap;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -908,7 +892,7 @@ rt2661_tx_intr(struct rt2661_softc *sc)
|
|||||||
ieee80211_ratectl_tx_complete(vap, ni,
|
ieee80211_ratectl_tx_complete(vap, ni,
|
||||||
IEEE80211_RATECTL_TX_SUCCESS,
|
IEEE80211_RATECTL_TX_SUCCESS,
|
||||||
&retrycnt, NULL);
|
&retrycnt, NULL);
|
||||||
ifp->if_opackets++;
|
error = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RT2661_TX_RETRY_FAIL:
|
case RT2661_TX_RETRY_FAIL:
|
||||||
@@ -920,14 +904,14 @@ rt2661_tx_intr(struct rt2661_softc *sc)
|
|||||||
ieee80211_ratectl_tx_complete(vap, ni,
|
ieee80211_ratectl_tx_complete(vap, ni,
|
||||||
IEEE80211_RATECTL_TX_FAILURE,
|
IEEE80211_RATECTL_TX_FAILURE,
|
||||||
&retrycnt, NULL);
|
&retrycnt, NULL);
|
||||||
ifp->if_oerrors++;
|
error = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* other failure */
|
/* other failure */
|
||||||
device_printf(sc->sc_dev,
|
device_printf(sc->sc_dev,
|
||||||
"sending data frame failed 0x%08x\n", val);
|
"sending data frame failed 0x%08x\n", val);
|
||||||
ifp->if_oerrors++;
|
error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINTFN(sc, 15, "tx done q=%d idx=%u\n", qid, txq->stat);
|
DPRINTFN(sc, 15, "tx done q=%d idx=%u\n", qid, txq->stat);
|
||||||
@@ -936,17 +920,12 @@ rt2661_tx_intr(struct rt2661_softc *sc)
|
|||||||
if (++txq->stat >= txq->count) /* faster than % count */
|
if (++txq->stat >= txq->count) /* faster than % count */
|
||||||
txq->stat = 0;
|
txq->stat = 0;
|
||||||
|
|
||||||
if (m->m_flags & M_TXCB)
|
ieee80211_tx_complete(ni, m, error);
|
||||||
ieee80211_process_callback(ni, m,
|
|
||||||
RT2661_TX_RESULT(val) != RT2661_TX_SUCCESS);
|
|
||||||
m_freem(m);
|
|
||||||
ieee80211_free_node(ni);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->sc_tx_timer = 0;
|
sc->sc_tx_timer = 0;
|
||||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
|
||||||
|
|
||||||
rt2661_start_locked(ifp);
|
rt2661_start(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -984,8 +963,7 @@ rt2661_tx_dma_intr(struct rt2661_softc *sc, struct rt2661_tx_ring *txq)
|
|||||||
static void
|
static void
|
||||||
rt2661_rx_intr(struct rt2661_softc *sc)
|
rt2661_rx_intr(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
struct rt2661_rx_desc *desc;
|
struct rt2661_rx_desc *desc;
|
||||||
struct rt2661_rx_data *data;
|
struct rt2661_rx_data *data;
|
||||||
bus_addr_t physaddr;
|
bus_addr_t physaddr;
|
||||||
@@ -1014,12 +992,12 @@ rt2661_rx_intr(struct rt2661_softc *sc)
|
|||||||
*/
|
*/
|
||||||
DPRINTFN(sc, 5, "PHY or CRC error flags 0x%08x\n",
|
DPRINTFN(sc, 5, "PHY or CRC error flags 0x%08x\n",
|
||||||
le32toh(desc->flags));
|
le32toh(desc->flags));
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((le32toh(desc->flags) & RT2661_RX_CIPHER_MASK) != 0) {
|
if ((le32toh(desc->flags) & RT2661_RX_CIPHER_MASK) != 0) {
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1032,7 +1010,7 @@ rt2661_rx_intr(struct rt2661_softc *sc)
|
|||||||
*/
|
*/
|
||||||
mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
||||||
if (mnew == NULL) {
|
if (mnew == NULL) {
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1055,7 +1033,7 @@ rt2661_rx_intr(struct rt2661_softc *sc)
|
|||||||
panic("%s: could not load old rx mbuf",
|
panic("%s: could not load old rx mbuf",
|
||||||
device_get_name(sc->sc_dev));
|
device_get_name(sc->sc_dev));
|
||||||
}
|
}
|
||||||
ifp->if_ierrors++;
|
counter_u64_add(ic->ic_ierrors, 1);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1068,7 +1046,6 @@ rt2661_rx_intr(struct rt2661_softc *sc)
|
|||||||
desc->physaddr = htole32(physaddr);
|
desc->physaddr = htole32(physaddr);
|
||||||
|
|
||||||
/* finalize mbuf */
|
/* finalize mbuf */
|
||||||
m->m_pkthdr.rcvif = ifp;
|
|
||||||
m->m_pkthdr.len = m->m_len =
|
m->m_pkthdr.len = m->m_len =
|
||||||
(le32toh(desc->flags) >> 16) & 0xfff;
|
(le32toh(desc->flags) >> 16) & 0xfff;
|
||||||
|
|
||||||
@@ -1153,7 +1130,6 @@ void
|
|||||||
rt2661_intr(void *arg)
|
rt2661_intr(void *arg)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = arg;
|
struct rt2661_softc *sc = arg;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
uint32_t r1, r2;
|
uint32_t r1, r2;
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
@@ -1164,7 +1140,7 @@ rt2661_intr(void *arg)
|
|||||||
RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff);
|
RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff);
|
||||||
|
|
||||||
/* don't re-enable interrupts if we're shutting down */
|
/* don't re-enable interrupts if we're shutting down */
|
||||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
if (!(sc->sc_flags & RAL_RUNNING)) {
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1241,8 +1217,7 @@ rt2661_setup_tx_desc(struct rt2661_softc *sc, struct rt2661_tx_desc *desc,
|
|||||||
uint32_t flags, uint16_t xflags, int len, int rate,
|
uint32_t flags, uint16_t xflags, int len, int rate,
|
||||||
const bus_dma_segment_t *segs, int nsegs, int ac)
|
const bus_dma_segment_t *segs, int nsegs, int ac)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint16_t plcp_length;
|
uint16_t plcp_length;
|
||||||
int i, remainder;
|
int i, remainder;
|
||||||
|
|
||||||
@@ -1278,7 +1253,7 @@ rt2661_setup_tx_desc(struct rt2661_softc *sc, struct rt2661_tx_desc *desc,
|
|||||||
desc->plcp_length_hi = plcp_length >> 6;
|
desc->plcp_length_hi = plcp_length >> 6;
|
||||||
desc->plcp_length_lo = plcp_length & 0x3f;
|
desc->plcp_length_lo = plcp_length & 0x3f;
|
||||||
} else {
|
} else {
|
||||||
plcp_length = (16 * len + rate - 1) / rate;
|
plcp_length = howmany(16 * len, rate);
|
||||||
if (rate == 22) {
|
if (rate == 22) {
|
||||||
remainder = (16 * len) % 22;
|
remainder = (16 * len) % 22;
|
||||||
if (remainder != 0 && remainder < 7)
|
if (remainder != 0 && remainder < 7)
|
||||||
@@ -1320,7 +1295,7 @@ rt2661_tx_mgt(struct rt2661_softc *sc, struct mbuf *m0,
|
|||||||
|
|
||||||
wh = mtod(m0, struct ieee80211_frame *);
|
wh = mtod(m0, struct ieee80211_frame *);
|
||||||
|
|
||||||
if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
||||||
k = ieee80211_crypto_encap(ni, m0);
|
k = ieee80211_crypto_encap(ni, m0);
|
||||||
if (k == NULL) {
|
if (k == NULL) {
|
||||||
m_freem(m0);
|
m_freem(m0);
|
||||||
@@ -1460,8 +1435,7 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
|
|||||||
struct ieee80211_node *ni, int ac)
|
struct ieee80211_node *ni, int ac)
|
||||||
{
|
{
|
||||||
struct ieee80211vap *vap = ni->ni_vap;
|
struct ieee80211vap *vap = ni->ni_vap;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
struct rt2661_tx_ring *txq = &sc->txq[ac];
|
struct rt2661_tx_ring *txq = &sc->txq[ac];
|
||||||
struct rt2661_tx_desc *desc;
|
struct rt2661_tx_desc *desc;
|
||||||
struct rt2661_tx_data *data;
|
struct rt2661_tx_data *data;
|
||||||
@@ -1495,7 +1469,7 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
|
|||||||
noack = cap->cap_wmeParams[ac].wmep_noackPolicy;
|
noack = cap->cap_wmeParams[ac].wmep_noackPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
||||||
k = ieee80211_crypto_encap(ni, m0);
|
k = ieee80211_crypto_encap(ni, m0);
|
||||||
if (k == NULL) {
|
if (k == NULL) {
|
||||||
m_freem(m0);
|
m_freem(m0);
|
||||||
@@ -1603,10 +1577,31 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
rt2661_start_locked(struct ifnet *ifp)
|
rt2661_transmit(struct ieee80211com *ic, struct mbuf *m)
|
||||||
|
{
|
||||||
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
RAL_LOCK(sc);
|
||||||
|
if ((sc->sc_flags & RAL_RUNNING) == 0) {
|
||||||
|
RAL_UNLOCK(sc);
|
||||||
|
return (ENXIO);
|
||||||
|
}
|
||||||
|
error = mbufq_enqueue(&sc->sc_snd, m);
|
||||||
|
if (error) {
|
||||||
|
RAL_UNLOCK(sc);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
rt2661_start(sc);
|
||||||
|
RAL_UNLOCK(sc);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rt2661_start(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
|
||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
struct ieee80211_node *ni;
|
struct ieee80211_node *ni;
|
||||||
int ac;
|
int ac;
|
||||||
@@ -1614,69 +1609,48 @@ rt2661_start_locked(struct ifnet *ifp)
|
|||||||
RAL_LOCK_ASSERT(sc);
|
RAL_LOCK_ASSERT(sc);
|
||||||
|
|
||||||
/* prevent management frames from being sent if we're not ready */
|
/* prevent management frames from being sent if we're not ready */
|
||||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING) || sc->sc_invalid)
|
if (!(sc->sc_flags & RAL_RUNNING) || sc->sc_invalid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (;;) {
|
while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
|
||||||
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
|
|
||||||
if (m == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ac = M_WME_GETAC(m);
|
ac = M_WME_GETAC(m);
|
||||||
if (sc->txq[ac].queued >= RT2661_TX_RING_COUNT - 1) {
|
if (sc->txq[ac].queued >= RT2661_TX_RING_COUNT - 1) {
|
||||||
/* there is no place left in this ring */
|
/* there is no place left in this ring */
|
||||||
IFQ_DRV_PREPEND(&ifp->if_snd, m);
|
mbufq_prepend(&sc->sc_snd, m);
|
||||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
|
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
|
||||||
if (rt2661_tx_data(sc, m, ni, ac) != 0) {
|
if (rt2661_tx_data(sc, m, ni, ac) != 0) {
|
||||||
|
if_inc_counter(ni->ni_vap->iv_ifp,
|
||||||
|
IFCOUNTER_OERRORS, 1);
|
||||||
ieee80211_free_node(ni);
|
ieee80211_free_node(ni);
|
||||||
ifp->if_oerrors++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->sc_tx_timer = 5;
|
sc->sc_tx_timer = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
rt2661_start(struct ifnet *ifp)
|
|
||||||
{
|
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
|
||||||
rt2661_start_locked(ifp);
|
|
||||||
RAL_UNLOCK(sc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rt2661_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
rt2661_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
||||||
const struct ieee80211_bpf_params *params)
|
const struct ieee80211_bpf_params *params)
|
||||||
{
|
{
|
||||||
struct ieee80211com *ic = ni->ni_ic;
|
struct ieee80211com *ic = ni->ni_ic;
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
|
|
||||||
/* prevent management frames from being sent if we're not ready */
|
/* prevent management frames from being sent if we're not ready */
|
||||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
if (!(sc->sc_flags & RAL_RUNNING)) {
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
ieee80211_free_node(ni);
|
|
||||||
return ENETDOWN;
|
return ENETDOWN;
|
||||||
}
|
}
|
||||||
if (sc->mgtq.queued >= RT2661_MGT_RING_COUNT) {
|
if (sc->mgtq.queued >= RT2661_MGT_RING_COUNT) {
|
||||||
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
ieee80211_free_node(ni);
|
|
||||||
return ENOBUFS; /* XXX */
|
return ENOBUFS; /* XXX */
|
||||||
}
|
}
|
||||||
|
|
||||||
ifp->if_opackets++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Legacy path; interpret frame contents to decide
|
* Legacy path; interpret frame contents to decide
|
||||||
* precisely how to send the frame.
|
* precisely how to send the frame.
|
||||||
@@ -1690,8 +1664,6 @@ rt2661_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
bad:
|
bad:
|
||||||
ifp->if_oerrors++;
|
|
||||||
ieee80211_free_node(ni);
|
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
return EIO; /* XXX */
|
return EIO; /* XXX */
|
||||||
}
|
}
|
||||||
@@ -1700,61 +1672,42 @@ static void
|
|||||||
rt2661_watchdog(void *arg)
|
rt2661_watchdog(void *arg)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = (struct rt2661_softc *)arg;
|
struct rt2661_softc *sc = (struct rt2661_softc *)arg;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
|
|
||||||
RAL_LOCK_ASSERT(sc);
|
RAL_LOCK_ASSERT(sc);
|
||||||
|
|
||||||
KASSERT(ifp->if_drv_flags & IFF_DRV_RUNNING, ("not running"));
|
KASSERT(sc->sc_flags & RAL_RUNNING, ("not running"));
|
||||||
|
|
||||||
if (sc->sc_invalid) /* card ejected */
|
if (sc->sc_invalid) /* card ejected */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
|
if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
|
||||||
if_printf(ifp, "device timeout\n");
|
device_printf(sc->sc_dev, "device timeout\n");
|
||||||
rt2661_init_locked(sc);
|
rt2661_init_locked(sc);
|
||||||
ifp->if_oerrors++;
|
counter_u64_add(sc->sc_ic.ic_oerrors, 1);
|
||||||
/* NB: callout is reset in rt2661_init() */
|
/* NB: callout is reset in rt2661_init() */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
|
callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
rt2661_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
rt2661_parent(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
int startall = 0;
|
||||||
struct ifreq *ifr = (struct ifreq *) data;
|
|
||||||
int error = 0, startall = 0;
|
|
||||||
|
|
||||||
switch (cmd) {
|
RAL_LOCK(sc);
|
||||||
case SIOCSIFFLAGS:
|
if (ic->ic_nrunning > 0) {
|
||||||
RAL_LOCK(sc);
|
if ((sc->sc_flags & RAL_RUNNING) == 0) {
|
||||||
if (ifp->if_flags & IFF_UP) {
|
rt2661_init_locked(sc);
|
||||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
|
startall = 1;
|
||||||
rt2661_init_locked(sc);
|
} else
|
||||||
startall = 1;
|
rt2661_update_promisc(ic);
|
||||||
} else
|
} else if (sc->sc_flags & RAL_RUNNING)
|
||||||
rt2661_update_promisc(ifp);
|
rt2661_stop_locked(sc);
|
||||||
} else {
|
RAL_UNLOCK(sc);
|
||||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
if (startall)
|
||||||
rt2661_stop_locked(sc);
|
ieee80211_start_all(ic);
|
||||||
}
|
|
||||||
RAL_UNLOCK(sc);
|
|
||||||
if (startall)
|
|
||||||
ieee80211_start_all(ic);
|
|
||||||
break;
|
|
||||||
case SIOCGIFMEDIA:
|
|
||||||
error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
|
|
||||||
break;
|
|
||||||
case SIOCGIFADDR:
|
|
||||||
error = ether_ioctl(ifp, cmd, data);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error = EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1878,8 +1831,7 @@ rt2661_select_antenna(struct rt2661_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2661_enable_mrr(struct rt2661_softc *sc)
|
rt2661_enable_mrr(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
tmp = RAL_READ(sc, RT2661_TXRX_CSR4);
|
tmp = RAL_READ(sc, RT2661_TXRX_CSR4);
|
||||||
@@ -1895,8 +1847,7 @@ rt2661_enable_mrr(struct rt2661_softc *sc)
|
|||||||
static void
|
static void
|
||||||
rt2661_set_txpreamble(struct rt2661_softc *sc)
|
rt2661_set_txpreamble(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
tmp = RAL_READ(sc, RT2661_TXRX_CSR4);
|
tmp = RAL_READ(sc, RT2661_TXRX_CSR4);
|
||||||
@@ -1912,9 +1863,7 @@ static void
|
|||||||
rt2661_set_basicrates(struct rt2661_softc *sc,
|
rt2661_set_basicrates(struct rt2661_softc *sc,
|
||||||
const struct ieee80211_rateset *rs)
|
const struct ieee80211_rateset *rs)
|
||||||
{
|
{
|
||||||
#define RV(r) ((r) & IEEE80211_RATE_VAL)
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint32_t mask = 0;
|
uint32_t mask = 0;
|
||||||
uint8_t rate;
|
uint8_t rate;
|
||||||
int i;
|
int i;
|
||||||
@@ -1925,13 +1874,13 @@ rt2661_set_basicrates(struct rt2661_softc *sc,
|
|||||||
if (!(rate & IEEE80211_RATE_BASIC))
|
if (!(rate & IEEE80211_RATE_BASIC))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mask |= 1 << ic->ic_rt->rateCodeToIndex[RV(rate)];
|
mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt,
|
||||||
|
IEEE80211_RV(rate));
|
||||||
}
|
}
|
||||||
|
|
||||||
RAL_WRITE(sc, RT2661_TXRX_CSR5, mask);
|
RAL_WRITE(sc, RT2661_TXRX_CSR5, mask);
|
||||||
|
|
||||||
DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask);
|
DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask);
|
||||||
#undef RV
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1983,8 +1932,7 @@ rt2661_select_band(struct rt2661_softc *sc, struct ieee80211_channel *c)
|
|||||||
static void
|
static void
|
||||||
rt2661_set_chan(struct rt2661_softc *sc, struct ieee80211_channel *c)
|
rt2661_set_chan(struct rt2661_softc *sc, struct ieee80211_channel *c)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
const struct rfprog *rfprog;
|
const struct rfprog *rfprog;
|
||||||
uint8_t bbp3, bbp94 = RT2661_BBPR94_DEFAULT;
|
uint8_t bbp3, bbp94 = RT2661_BBPR94_DEFAULT;
|
||||||
int8_t power;
|
int8_t power;
|
||||||
@@ -2079,21 +2027,21 @@ rt2661_set_macaddr(struct rt2661_softc *sc, const uint8_t *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2661_update_promisc(struct ifnet *ifp)
|
rt2661_update_promisc(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
tmp = RAL_READ(sc, RT2661_TXRX_CSR0);
|
tmp = RAL_READ(sc, RT2661_TXRX_CSR0);
|
||||||
|
|
||||||
tmp &= ~RT2661_DROP_NOT_TO_ME;
|
tmp &= ~RT2661_DROP_NOT_TO_ME;
|
||||||
if (!(ifp->if_flags & IFF_PROMISC))
|
if (ic->ic_promisc == 0)
|
||||||
tmp |= RT2661_DROP_NOT_TO_ME;
|
tmp |= RT2661_DROP_NOT_TO_ME;
|
||||||
|
|
||||||
RAL_WRITE(sc, RT2661_TXRX_CSR0, tmp);
|
RAL_WRITE(sc, RT2661_TXRX_CSR0, tmp);
|
||||||
|
|
||||||
DPRINTF(sc, "%s promiscuous mode\n", (ifp->if_flags & IFF_PROMISC) ?
|
DPRINTF(sc, "%s promiscuous mode\n",
|
||||||
"entering" : "leaving");
|
(ic->ic_promisc > 0) ? "entering" : "leaving");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2102,7 +2050,7 @@ rt2661_update_promisc(struct ifnet *ifp)
|
|||||||
static int
|
static int
|
||||||
rt2661_wme_update(struct ieee80211com *ic)
|
rt2661_wme_update(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = ic->ic_ifp->if_softc;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
const struct wmeParams *wmep;
|
const struct wmeParams *wmep;
|
||||||
|
|
||||||
wmep = ic->ic_wme.wme_chanParams.cap_wmeParams;
|
wmep = ic->ic_wme.wme_chanParams.cap_wmeParams;
|
||||||
@@ -2143,14 +2091,13 @@ rt2661_wme_update(struct ieee80211com *ic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2661_update_slot(struct ifnet *ifp)
|
rt2661_update_slot(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint8_t slottime;
|
uint8_t slottime;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
|
slottime = IEEE80211_GET_SLOTTIME(ic);
|
||||||
|
|
||||||
tmp = RAL_READ(sc, RT2661_MAC_CSR9);
|
tmp = RAL_READ(sc, RT2661_MAC_CSR9);
|
||||||
tmp = (tmp & ~0xff) | slottime;
|
tmp = (tmp & ~0xff) | slottime;
|
||||||
@@ -2264,7 +2211,6 @@ rt2661_read_eeprom(struct rt2661_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN])
|
|||||||
static int
|
static int
|
||||||
rt2661_bbp_init(struct rt2661_softc *sc)
|
rt2661_bbp_init(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
#define N(a) (sizeof (a) / sizeof ((a)[0]))
|
|
||||||
int i, ntries;
|
int i, ntries;
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
|
|
||||||
@@ -2281,7 +2227,7 @@ rt2661_bbp_init(struct rt2661_softc *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* initialize BBP registers to default values */
|
/* initialize BBP registers to default values */
|
||||||
for (i = 0; i < N(rt2661_def_bbp); i++) {
|
for (i = 0; i < nitems(rt2661_def_bbp); i++) {
|
||||||
rt2661_bbp_write(sc, rt2661_def_bbp[i].reg,
|
rt2661_bbp_write(sc, rt2661_def_bbp[i].reg,
|
||||||
rt2661_def_bbp[i].val);
|
rt2661_def_bbp[i].val);
|
||||||
}
|
}
|
||||||
@@ -2294,15 +2240,13 @@ rt2661_bbp_init(struct rt2661_softc *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#undef N
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2661_init_locked(struct rt2661_softc *sc)
|
rt2661_init_locked(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
#define N(a) (sizeof (a) / sizeof ((a)[0]))
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
uint32_t tmp, sta[3];
|
uint32_t tmp, sta[3];
|
||||||
int i, error, ntries;
|
int i, error, ntries;
|
||||||
|
|
||||||
@@ -2311,7 +2255,7 @@ rt2661_init_locked(struct rt2661_softc *sc)
|
|||||||
if ((sc->sc_flags & RAL_FW_LOADED) == 0) {
|
if ((sc->sc_flags & RAL_FW_LOADED) == 0) {
|
||||||
error = rt2661_load_microcode(sc);
|
error = rt2661_load_microcode(sc);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
if_printf(ifp,
|
device_printf(sc->sc_dev,
|
||||||
"%s: could not load 8051 microcode, error %d\n",
|
"%s: could not load 8051 microcode, error %d\n",
|
||||||
__func__, error);
|
__func__, error);
|
||||||
return;
|
return;
|
||||||
@@ -2361,10 +2305,10 @@ rt2661_init_locked(struct rt2661_softc *sc)
|
|||||||
RAL_WRITE(sc, RT2661_RX_CNTL_CSR, 2);
|
RAL_WRITE(sc, RT2661_RX_CNTL_CSR, 2);
|
||||||
|
|
||||||
/* initialize MAC registers to default values */
|
/* initialize MAC registers to default values */
|
||||||
for (i = 0; i < N(rt2661_def_mac); i++)
|
for (i = 0; i < nitems(rt2661_def_mac); i++)
|
||||||
RAL_WRITE(sc, rt2661_def_mac[i].reg, rt2661_def_mac[i].val);
|
RAL_WRITE(sc, rt2661_def_mac[i].reg, rt2661_def_mac[i].val);
|
||||||
|
|
||||||
rt2661_set_macaddr(sc, IF_LLADDR(ifp));
|
rt2661_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr);
|
||||||
|
|
||||||
/* set host ready */
|
/* set host ready */
|
||||||
RAL_WRITE(sc, RT2661_MAC_CSR1, 3);
|
RAL_WRITE(sc, RT2661_MAC_CSR1, 3);
|
||||||
@@ -2403,14 +2347,14 @@ rt2661_init_locked(struct rt2661_softc *sc)
|
|||||||
if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
|
if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
|
||||||
ic->ic_opmode != IEEE80211_M_MBSS)
|
ic->ic_opmode != IEEE80211_M_MBSS)
|
||||||
tmp |= RT2661_DROP_TODS;
|
tmp |= RT2661_DROP_TODS;
|
||||||
if (!(ifp->if_flags & IFF_PROMISC))
|
if (ic->ic_promisc == 0)
|
||||||
tmp |= RT2661_DROP_NOT_TO_ME;
|
tmp |= RT2661_DROP_NOT_TO_ME;
|
||||||
}
|
}
|
||||||
|
|
||||||
RAL_WRITE(sc, RT2661_TXRX_CSR0, tmp);
|
RAL_WRITE(sc, RT2661_TXRX_CSR0, tmp);
|
||||||
|
|
||||||
/* clear STA registers */
|
/* clear STA registers */
|
||||||
RAL_READ_REGION_4(sc, RT2661_STA_CSR0, sta, N(sta));
|
RAL_READ_REGION_4(sc, RT2661_STA_CSR0, sta, nitems(sta));
|
||||||
|
|
||||||
/* initialize ASIC */
|
/* initialize ASIC */
|
||||||
RAL_WRITE(sc, RT2661_MAC_CSR1, 4);
|
RAL_WRITE(sc, RT2661_MAC_CSR1, 4);
|
||||||
@@ -2425,34 +2369,30 @@ rt2661_init_locked(struct rt2661_softc *sc)
|
|||||||
/* kick Rx */
|
/* kick Rx */
|
||||||
RAL_WRITE(sc, RT2661_RX_CNTL_CSR, 1);
|
RAL_WRITE(sc, RT2661_RX_CNTL_CSR, 1);
|
||||||
|
|
||||||
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
sc->sc_flags |= RAL_RUNNING;
|
||||||
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
|
||||||
|
|
||||||
callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
|
callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
|
||||||
#undef N
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2661_init(void *priv)
|
rt2661_init(void *priv)
|
||||||
{
|
{
|
||||||
struct rt2661_softc *sc = priv;
|
struct rt2661_softc *sc = priv;
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
rt2661_init_locked(sc);
|
rt2661_init_locked(sc);
|
||||||
RAL_UNLOCK(sc);
|
RAL_UNLOCK(sc);
|
||||||
|
|
||||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
if (sc->sc_flags & RAL_RUNNING)
|
||||||
ieee80211_start_all(ic); /* start all vap's */
|
ieee80211_start_all(ic); /* start all vap's */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rt2661_stop_locked(struct rt2661_softc *sc)
|
rt2661_stop_locked(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
uint32_t tmp;
|
|
||||||
volatile int *flags = &sc->sc_flags;
|
volatile int *flags = &sc->sc_flags;
|
||||||
|
uint32_t tmp;
|
||||||
|
|
||||||
while (*flags & RAL_INPUT_RUNNING)
|
while (*flags & RAL_INPUT_RUNNING)
|
||||||
msleep(sc, &sc->sc_mtx, 0, "ralrunning", hz/10);
|
msleep(sc, &sc->sc_mtx, 0, "ralrunning", hz/10);
|
||||||
@@ -2460,8 +2400,8 @@ rt2661_stop_locked(struct rt2661_softc *sc)
|
|||||||
callout_stop(&sc->watchdog_ch);
|
callout_stop(&sc->watchdog_ch);
|
||||||
sc->sc_tx_timer = 0;
|
sc->sc_tx_timer = 0;
|
||||||
|
|
||||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
if (sc->sc_flags & RAL_RUNNING) {
|
||||||
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
sc->sc_flags &= ~RAL_RUNNING;
|
||||||
|
|
||||||
/* abort Tx (for all 5 Tx rings) */
|
/* abort Tx (for all 5 Tx rings) */
|
||||||
RAL_WRITE(sc, RT2661_TX_CNTL_CSR, 0x1f << 16);
|
RAL_WRITE(sc, RT2661_TX_CNTL_CSR, 0x1f << 16);
|
||||||
@@ -2505,7 +2445,6 @@ rt2661_stop(void *priv)
|
|||||||
static int
|
static int
|
||||||
rt2661_load_microcode(struct rt2661_softc *sc)
|
rt2661_load_microcode(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
|
||||||
const struct firmware *fp;
|
const struct firmware *fp;
|
||||||
const char *imagename;
|
const char *imagename;
|
||||||
int ntries, error;
|
int ntries, error;
|
||||||
@@ -2517,7 +2456,7 @@ rt2661_load_microcode(struct rt2661_softc *sc)
|
|||||||
case 0x0302: imagename = "rt2561fw"; break;
|
case 0x0302: imagename = "rt2561fw"; break;
|
||||||
case 0x0401: imagename = "rt2661fw"; break;
|
case 0x0401: imagename = "rt2661fw"; break;
|
||||||
default:
|
default:
|
||||||
if_printf(ifp, "%s: unexpected pci device id 0x%x, "
|
device_printf(sc->sc_dev, "%s: unexpected pci device id 0x%x, "
|
||||||
"don't know how to retrieve firmware\n",
|
"don't know how to retrieve firmware\n",
|
||||||
__func__, sc->sc_id);
|
__func__, sc->sc_id);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
@@ -2526,7 +2465,8 @@ rt2661_load_microcode(struct rt2661_softc *sc)
|
|||||||
fp = firmware_get(imagename);
|
fp = firmware_get(imagename);
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
if_printf(ifp, "%s: unable to retrieve firmware image %s\n",
|
device_printf(sc->sc_dev,
|
||||||
|
"%s: unable to retrieve firmware image %s\n",
|
||||||
__func__, imagename);
|
__func__, imagename);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
@@ -2557,8 +2497,8 @@ rt2661_load_microcode(struct rt2661_softc *sc)
|
|||||||
DELAY(100);
|
DELAY(100);
|
||||||
}
|
}
|
||||||
if (ntries == 500) {
|
if (ntries == 500) {
|
||||||
if_printf(ifp, "%s: timeout waiting for MCU to initialize\n",
|
device_printf(sc->sc_dev,
|
||||||
__func__);
|
"%s: timeout waiting for MCU to initialize\n", __func__);
|
||||||
error = EIO;
|
error = EIO;
|
||||||
} else
|
} else
|
||||||
error = 0;
|
error = 0;
|
||||||
@@ -2690,13 +2630,11 @@ static int
|
|||||||
rt2661_prepare_beacon(struct rt2661_softc *sc, struct ieee80211vap *vap)
|
rt2661_prepare_beacon(struct rt2661_softc *sc, struct ieee80211vap *vap)
|
||||||
{
|
{
|
||||||
struct ieee80211com *ic = vap->iv_ic;
|
struct ieee80211com *ic = vap->iv_ic;
|
||||||
struct ieee80211_beacon_offsets bo;
|
|
||||||
struct rt2661_tx_desc desc;
|
struct rt2661_tx_desc desc;
|
||||||
struct mbuf *m0;
|
struct mbuf *m0;
|
||||||
int rate;
|
int rate;
|
||||||
|
|
||||||
m0 = ieee80211_beacon_alloc(vap->iv_bss, &bo);
|
if ((m0 = ieee80211_beacon_alloc(vap->iv_bss))== NULL) {
|
||||||
if (m0 == NULL) {
|
|
||||||
device_printf(sc->sc_dev, "could not allocate beacon frame\n");
|
device_printf(sc->sc_dev, "could not allocate beacon frame\n");
|
||||||
return ENOBUFS;
|
return ENOBUFS;
|
||||||
}
|
}
|
||||||
@@ -2726,8 +2664,7 @@ rt2661_prepare_beacon(struct rt2661_softc *sc, struct ieee80211vap *vap)
|
|||||||
static void
|
static void
|
||||||
rt2661_enable_tsf_sync(struct rt2661_softc *sc)
|
rt2661_enable_tsf_sync(struct rt2661_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = sc->sc_ifp;
|
struct ieee80211com *ic = &sc->sc_ic;
|
||||||
struct ieee80211com *ic = ifp->if_l2com;
|
|
||||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
@@ -2811,21 +2748,19 @@ rt2661_get_rssi(struct rt2661_softc *sc, uint8_t raw)
|
|||||||
static void
|
static void
|
||||||
rt2661_scan_start(struct ieee80211com *ic)
|
rt2661_scan_start(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
/* abort TSF synchronization */
|
/* abort TSF synchronization */
|
||||||
tmp = RAL_READ(sc, RT2661_TXRX_CSR9);
|
tmp = RAL_READ(sc, RT2661_TXRX_CSR9);
|
||||||
RAL_WRITE(sc, RT2661_TXRX_CSR9, tmp & ~0xffffff);
|
RAL_WRITE(sc, RT2661_TXRX_CSR9, tmp & ~0xffffff);
|
||||||
rt2661_set_bssid(sc, ifp->if_broadcastaddr);
|
rt2661_set_bssid(sc, ieee80211broadcastaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2661_scan_end(struct ieee80211com *ic)
|
rt2661_scan_end(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
|
||||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
||||||
|
|
||||||
rt2661_enable_tsf_sync(sc);
|
rt2661_enable_tsf_sync(sc);
|
||||||
@@ -2833,11 +2768,30 @@ rt2661_scan_end(struct ieee80211com *ic)
|
|||||||
rt2661_set_bssid(sc, vap->iv_bss->ni_bssid);
|
rt2661_set_bssid(sc, vap->iv_bss->ni_bssid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rt2661_getradiocaps(struct ieee80211com *ic,
|
||||||
|
int maxchans, int *nchans, struct ieee80211_channel chans[])
|
||||||
|
{
|
||||||
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
|
uint8_t bands[IEEE80211_MODE_BYTES];
|
||||||
|
|
||||||
|
memset(bands, 0, sizeof(bands));
|
||||||
|
setbit(bands, IEEE80211_MODE_11B);
|
||||||
|
setbit(bands, IEEE80211_MODE_11G);
|
||||||
|
ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
|
||||||
|
rt2661_chan_2ghz, nitems(rt2661_chan_2ghz), bands, 0);
|
||||||
|
|
||||||
|
if (sc->rf_rev == RT2661_RF_5225 || sc->rf_rev == RT2661_RF_5325) {
|
||||||
|
setbit(bands, IEEE80211_MODE_11A);
|
||||||
|
ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
|
||||||
|
rt2661_chan_5ghz, nitems(rt2661_chan_5ghz), bands, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rt2661_set_channel(struct ieee80211com *ic)
|
rt2661_set_channel(struct ieee80211com *ic)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp = ic->ic_ifp;
|
struct rt2661_softc *sc = ic->ic_softc;
|
||||||
struct rt2661_softc *sc = ifp->if_softc;
|
|
||||||
|
|
||||||
RAL_LOCK(sc);
|
RAL_LOCK(sc);
|
||||||
rt2661_set_chan(sc, ic->ic_curchan);
|
rt2661_set_chan(sc, ic->ic_curchan);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2661reg.h 258780 2013-11-30 22:17:27Z eadler $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006
|
* Copyright (c) 2006
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
|
|
||||||
/* possible flags for register PHY_CSR4 */
|
/* possible flags for register PHY_CSR4 */
|
||||||
#define RT2661_RF_21BIT (21 << 24)
|
#define RT2661_RF_21BIT (21 << 24)
|
||||||
#define RT2661_RF_BUSY (1 << 31)
|
#define RT2661_RF_BUSY (1U << 31)
|
||||||
|
|
||||||
/* possible values for register STA_CSR4 */
|
/* possible values for register STA_CSR4 */
|
||||||
#define RT2661_TX_STAT_VALID (1 << 0)
|
#define RT2661_TX_STAT_VALID (1 << 0)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2661var.h 300657 2016-05-25 06:29:23Z sgalabov $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005
|
* Copyright (c) 2005
|
||||||
@@ -26,7 +26,7 @@ struct rt2661_rx_radiotap_header {
|
|||||||
uint16_t wr_chan_flags;
|
uint16_t wr_chan_flags;
|
||||||
int8_t wr_antsignal;
|
int8_t wr_antsignal;
|
||||||
int8_t wr_antnoise;
|
int8_t wr_antnoise;
|
||||||
} __packed;
|
} __packed __aligned(8);
|
||||||
|
|
||||||
#define RT2661_RX_RADIOTAP_PRESENT \
|
#define RT2661_RX_RADIOTAP_PRESENT \
|
||||||
((1 << IEEE80211_RADIOTAP_TSFT) | \
|
((1 << IEEE80211_RADIOTAP_TSFT) | \
|
||||||
@@ -42,7 +42,7 @@ struct rt2661_tx_radiotap_header {
|
|||||||
uint8_t wt_rate;
|
uint8_t wt_rate;
|
||||||
uint16_t wt_chan_freq;
|
uint16_t wt_chan_freq;
|
||||||
uint16_t wt_chan_flags;
|
uint16_t wt_chan_flags;
|
||||||
} __packed;
|
} __packed __aligned(8);
|
||||||
|
|
||||||
#define RT2661_TX_RADIOTAP_PRESENT \
|
#define RT2661_TX_RADIOTAP_PRESENT \
|
||||||
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||||
@@ -97,13 +97,13 @@ struct rt2661_vap {
|
|||||||
#define RT2661_VAP(vap) ((struct rt2661_vap *)(vap))
|
#define RT2661_VAP(vap) ((struct rt2661_vap *)(vap))
|
||||||
|
|
||||||
struct rt2661_softc {
|
struct rt2661_softc {
|
||||||
struct ifnet *sc_ifp;
|
struct ieee80211com sc_ic;
|
||||||
|
struct mtx sc_mtx;
|
||||||
|
struct mbufq sc_snd;
|
||||||
device_t sc_dev;
|
device_t sc_dev;
|
||||||
bus_space_tag_t sc_st;
|
bus_space_tag_t sc_st;
|
||||||
bus_space_handle_t sc_sh;
|
bus_space_handle_t sc_sh;
|
||||||
|
|
||||||
struct mtx sc_mtx;
|
|
||||||
|
|
||||||
struct callout watchdog_ch;
|
struct callout watchdog_ch;
|
||||||
|
|
||||||
int sc_tx_timer;
|
int sc_tx_timer;
|
||||||
@@ -117,6 +117,7 @@ struct rt2661_softc {
|
|||||||
int sc_flags;
|
int sc_flags;
|
||||||
#define RAL_FW_LOADED 0x1
|
#define RAL_FW_LOADED 0x1
|
||||||
#define RAL_INPUT_RUNNING 0x2
|
#define RAL_INPUT_RUNNING 0x2
|
||||||
|
#define RAL_RUNNING 0x4
|
||||||
int sc_id;
|
int sc_id;
|
||||||
struct ieee80211_channel *sc_curchan;
|
struct ieee80211_channel *sc_curchan;
|
||||||
|
|
||||||
@@ -156,9 +157,7 @@ struct rt2661_softc {
|
|||||||
int dwelltime;
|
int dwelltime;
|
||||||
|
|
||||||
struct rt2661_rx_radiotap_header sc_rxtap;
|
struct rt2661_rx_radiotap_header sc_rxtap;
|
||||||
int sc_rxtap_len;
|
|
||||||
struct rt2661_tx_radiotap_header sc_txtap;
|
struct rt2661_tx_radiotap_header sc_txtap;
|
||||||
int sc_txtap_len;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int rt2661_attach(device_t, int);
|
int rt2661_attach(device_t, int);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: rt2860reg.h,v 1.30 2010/05/10 18:17:10 damien Exp $
|
* $OpenBSD: rt2860reg.h,v 1.30 2010/05/10 18:17:10 damien Exp $
|
||||||
* $FreeBSD$
|
* $FreeBSD: releng/11.1/sys/dev/ral/rt2860reg.h 301575 2016-06-08 02:37:23Z kevlo $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define RT2860_NOISE_FLOOR -95
|
#define RT2860_NOISE_FLOOR -95
|
||||||
@@ -257,8 +257,17 @@
|
|||||||
#define RT2860_TX_DMA_BUSY (1 << 1)
|
#define RT2860_TX_DMA_BUSY (1 << 1)
|
||||||
#define RT2860_TX_DMA_EN (1 << 0)
|
#define RT2860_TX_DMA_EN (1 << 0)
|
||||||
|
|
||||||
|
/* flags for register WPDMA_RST_IDX */
|
||||||
|
#define RT2860_RST_DRX_IDX0 (1 << 16)
|
||||||
|
#define RT2860_RST_DTX_IDX5 (1 << 5)
|
||||||
|
#define RT2860_RST_DTX_IDX4 (1 << 4)
|
||||||
|
#define RT2860_RST_DTX_IDX3 (1 << 3)
|
||||||
|
#define RT2860_RST_DTX_IDX2 (1 << 2)
|
||||||
|
#define RT2860_RST_DTX_IDX1 (1 << 1)
|
||||||
|
#define RT2860_RST_DTX_IDX0 (1 << 0)
|
||||||
|
|
||||||
/* possible flags for register DELAY_INT_CFG */
|
/* possible flags for register DELAY_INT_CFG */
|
||||||
#define RT2860_TXDLY_INT_EN (1 << 31)
|
#define RT2860_TXDLY_INT_EN (1U << 31)
|
||||||
#define RT2860_TXMAX_PINT_SHIFT 24
|
#define RT2860_TXMAX_PINT_SHIFT 24
|
||||||
#define RT2860_TXMAX_PTIME_SHIFT 16
|
#define RT2860_TXMAX_PTIME_SHIFT 16
|
||||||
#define RT2860_RXDLY_INT_EN (1 << 15)
|
#define RT2860_RXDLY_INT_EN (1 << 15)
|
||||||
@@ -270,7 +279,7 @@
|
|||||||
#define RT2860_GPIO_O_SHIFT 0
|
#define RT2860_GPIO_O_SHIFT 0
|
||||||
|
|
||||||
/* possible flags for register USB_DMA_CFG */
|
/* possible flags for register USB_DMA_CFG */
|
||||||
#define RT2860_USB_TX_BUSY (1 << 31)
|
#define RT2860_USB_TX_BUSY (1U << 31)
|
||||||
#define RT2860_USB_RX_BUSY (1 << 30)
|
#define RT2860_USB_RX_BUSY (1 << 30)
|
||||||
#define RT2860_USB_EPOUT_VLD_SHIFT 24
|
#define RT2860_USB_EPOUT_VLD_SHIFT 24
|
||||||
#define RT2860_USB_TX_EN (1 << 23)
|
#define RT2860_USB_TX_EN (1 << 23)
|
||||||
@@ -370,7 +379,7 @@
|
|||||||
#define RT2860_TX0Q_PCNT_MASK 0x000000ff
|
#define RT2860_TX0Q_PCNT_MASK 0x000000ff
|
||||||
|
|
||||||
/* possible flags for register CAP_CTRL */
|
/* possible flags for register CAP_CTRL */
|
||||||
#define RT2860_CAP_ADC_FEQ (1 << 31)
|
#define RT2860_CAP_ADC_FEQ (1U << 31)
|
||||||
#define RT2860_CAP_START (1 << 30)
|
#define RT2860_CAP_START (1 << 30)
|
||||||
#define RT2860_MAN_TRIG (1 << 29)
|
#define RT2860_MAN_TRIG (1 << 29)
|
||||||
#define RT2860_TRIG_OFFSET_SHIFT 16
|
#define RT2860_TRIG_OFFSET_SHIFT 16
|
||||||
@@ -381,7 +390,7 @@
|
|||||||
#define RT3070_RF_WRITE (1 << 16)
|
#define RT3070_RF_WRITE (1 << 16)
|
||||||
|
|
||||||
/* possible flags for register EFUSE_CTRL */
|
/* possible flags for register EFUSE_CTRL */
|
||||||
#define RT3070_SEL_EFUSE (1 << 31)
|
#define RT3070_SEL_EFUSE (1U << 31)
|
||||||
#define RT3070_EFSROM_KICK (1 << 30)
|
#define RT3070_EFSROM_KICK (1 << 30)
|
||||||
#define RT3070_EFSROM_AIN_MASK 0x03ff0000
|
#define RT3070_EFSROM_AIN_MASK 0x03ff0000
|
||||||
#define RT3070_EFSROM_AIN_SHIFT 16
|
#define RT3070_EFSROM_AIN_SHIFT 16
|
||||||
@@ -420,7 +429,7 @@
|
|||||||
#define RT2860_BBP_DATA_SHIFT 0
|
#define RT2860_BBP_DATA_SHIFT 0
|
||||||
|
|
||||||
/* possible flags for register RF_CSR_CFG0 */
|
/* possible flags for register RF_CSR_CFG0 */
|
||||||
#define RT2860_RF_REG_CTRL (1 << 31)
|
#define RT2860_RF_REG_CTRL (1U << 31)
|
||||||
#define RT2860_RF_LE_SEL1 (1 << 30)
|
#define RT2860_RF_LE_SEL1 (1 << 30)
|
||||||
#define RT2860_RF_LE_STBY (1 << 29)
|
#define RT2860_RF_LE_STBY (1 << 29)
|
||||||
#define RT2860_RF_REG_WIDTH_SHIFT 24
|
#define RT2860_RF_REG_WIDTH_SHIFT 24
|
||||||
@@ -455,7 +464,7 @@
|
|||||||
#define RT2860_SLOT_TIME 0
|
#define RT2860_SLOT_TIME 0
|
||||||
|
|
||||||
/* possible flags for register NAV_TIME_CFG */
|
/* possible flags for register NAV_TIME_CFG */
|
||||||
#define RT2860_NAV_UPD (1 << 31)
|
#define RT2860_NAV_UPD (1U << 31)
|
||||||
#define RT2860_NAV_UPD_VAL_SHIFT 16
|
#define RT2860_NAV_UPD_VAL_SHIFT 16
|
||||||
#define RT2860_NAV_CLR_EN (1 << 15)
|
#define RT2860_NAV_CLR_EN (1 << 15)
|
||||||
#define RT2860_NAV_TIMER_SHIFT 0
|
#define RT2860_NAV_TIMER_SHIFT 0
|
||||||
@@ -509,7 +518,7 @@
|
|||||||
#define RT2860_WAKEUP_LEAD_TIME_SHIFT 0
|
#define RT2860_WAKEUP_LEAD_TIME_SHIFT 0
|
||||||
|
|
||||||
/* possible flags for register TX_PIN_CFG */
|
/* possible flags for register TX_PIN_CFG */
|
||||||
#define RT3593_LNA_PE_G2_POL (1 << 31)
|
#define RT3593_LNA_PE_G2_POL (1U << 31)
|
||||||
#define RT3593_LNA_PE_A2_POL (1 << 30)
|
#define RT3593_LNA_PE_A2_POL (1 << 30)
|
||||||
#define RT3593_LNA_PE_G2_EN (1 << 29)
|
#define RT3593_LNA_PE_G2_EN (1 << 29)
|
||||||
#define RT3593_LNA_PE_A2_EN (1 << 28)
|
#define RT3593_LNA_PE_A2_EN (1 << 28)
|
||||||
@@ -699,6 +708,7 @@
|
|||||||
|
|
||||||
/* possible flags for RT3020 RF register 1 */
|
/* possible flags for RT3020 RF register 1 */
|
||||||
#define RT3070_RF_BLOCK (1 << 0)
|
#define RT3070_RF_BLOCK (1 << 0)
|
||||||
|
#define RT3070_PLL_PD (1 << 1)
|
||||||
#define RT3070_RX0_PD (1 << 2)
|
#define RT3070_RX0_PD (1 << 2)
|
||||||
#define RT3070_TX0_PD (1 << 3)
|
#define RT3070_TX0_PD (1 << 3)
|
||||||
#define RT3070_RX1_PD (1 << 4)
|
#define RT3070_RX1_PD (1 << 4)
|
||||||
@@ -750,6 +760,22 @@
|
|||||||
|
|
||||||
#define RT3090_DEF_LNA 10
|
#define RT3090_DEF_LNA 10
|
||||||
|
|
||||||
|
/* possible flags for RT5390 RF register 38 */
|
||||||
|
#define RT5390_RX_LO1 (1 << 5)
|
||||||
|
|
||||||
|
/* possible flags for RT5390 RF register 39 */
|
||||||
|
#define RT5390_RX_LO2 (1 << 7)
|
||||||
|
|
||||||
|
/* possible flags for RT5390 RF register 42 */
|
||||||
|
#define RT5390_RX_CTB (1 << 6)
|
||||||
|
|
||||||
|
/* possible flags for RT5390 BBP register 4 */
|
||||||
|
#define RT5390_MAC_IF_CTRL (1 << 6)
|
||||||
|
|
||||||
|
/* possible flags for RT5390 BBP register 105 */
|
||||||
|
#define RT5390_MLD (1 << 2)
|
||||||
|
#define RT5390_SIG_MODULATION (1 << 3)
|
||||||
|
|
||||||
/* RT2860 TX descriptor */
|
/* RT2860 TX descriptor */
|
||||||
struct rt2860_txd {
|
struct rt2860_txd {
|
||||||
uint32_t sdp0; /* Segment Data Pointer 0 */
|
uint32_t sdp0; /* Segment Data Pointer 0 */
|
||||||
@@ -883,17 +909,19 @@ struct rt2860_rxwi {
|
|||||||
#define RT2860_RF3 1
|
#define RT2860_RF3 1
|
||||||
#define RT2860_RF4 3
|
#define RT2860_RF4 3
|
||||||
|
|
||||||
#define RT2860_RF_2820 1 /* 2T3R */
|
#define RT2860_RF_2820 0x0001 /* 2T3R */
|
||||||
#define RT2860_RF_2850 2 /* dual-band 2T3R */
|
#define RT2860_RF_2850 0x0002 /* dual-band 2T3R */
|
||||||
#define RT2860_RF_2720 3 /* 1T2R */
|
#define RT2860_RF_2720 0x0003 /* 1T2R */
|
||||||
#define RT2860_RF_2750 4 /* dual-band 1T2R */
|
#define RT2860_RF_2750 0x0004 /* dual-band 1T2R */
|
||||||
#define RT3070_RF_3020 5 /* 1T1R */
|
#define RT3070_RF_3020 0x0005 /* 1T1R */
|
||||||
#define RT3070_RF_2020 6 /* b/g */
|
#define RT3070_RF_2020 0x0006 /* b/g */
|
||||||
#define RT3070_RF_3021 7 /* 1T2R */
|
#define RT3070_RF_3021 0x0007 /* 1T2R */
|
||||||
#define RT3070_RF_3022 8 /* 2T2R */
|
#define RT3070_RF_3022 0x0008 /* 2T2R */
|
||||||
#define RT3070_RF_3052 9 /* dual-band 2T2R */
|
#define RT3070_RF_3052 0x0009 /* dual-band 2T2R */
|
||||||
#define RT3070_RF_3320 11 /* 1T1R */
|
#define RT3070_RF_3320 0x000b /* 1T1R */
|
||||||
#define RT3070_RF_3053 13 /* dual-band 3T3R */
|
#define RT3070_RF_3053 0x000d /* dual-band 3T3R */
|
||||||
|
#define RT5390_RF_5360 0x5360 /* 1T1R */
|
||||||
|
#define RT5390_RF_5390 0x5390 /* 1T1R */
|
||||||
|
|
||||||
/* USB commands for RT2870 only */
|
/* USB commands for RT2870 only */
|
||||||
#define RT2870_RESET 1
|
#define RT2870_RESET 1
|
||||||
@@ -904,6 +932,7 @@ struct rt2860_rxwi {
|
|||||||
|
|
||||||
#define RT2860_EEPROM_DELAY 1 /* minimum hold time (microsecond) */
|
#define RT2860_EEPROM_DELAY 1 /* minimum hold time (microsecond) */
|
||||||
|
|
||||||
|
#define RT2860_EEPROM_CHIPID 0x00
|
||||||
#define RT2860_EEPROM_VERSION 0x01
|
#define RT2860_EEPROM_VERSION 0x01
|
||||||
#define RT2860_EEPROM_MAC01 0x02
|
#define RT2860_EEPROM_MAC01 0x02
|
||||||
#define RT2860_EEPROM_MAC23 0x03
|
#define RT2860_EEPROM_MAC23 0x03
|
||||||
@@ -1006,14 +1035,17 @@ static const struct rt2860_rate {
|
|||||||
*/
|
*/
|
||||||
#define RT2860_DEF_MAC \
|
#define RT2860_DEF_MAC \
|
||||||
{ RT2860_BCN_OFFSET0, 0xf8f0e8e0 }, \
|
{ RT2860_BCN_OFFSET0, 0xf8f0e8e0 }, \
|
||||||
|
{ RT2860_BCN_OFFSET1, 0x6f77d0c8 }, \
|
||||||
{ RT2860_LEGACY_BASIC_RATE, 0x0000013f }, \
|
{ RT2860_LEGACY_BASIC_RATE, 0x0000013f }, \
|
||||||
{ RT2860_HT_BASIC_RATE, 0x00008003 }, \
|
{ RT2860_HT_BASIC_RATE, 0x00008003 }, \
|
||||||
{ RT2860_MAC_SYS_CTRL, 0x00000000 }, \
|
{ RT2860_MAC_SYS_CTRL, 0x00000000 }, \
|
||||||
|
{ RT2860_RX_FILTR_CFG, 0x00017f97 }, \
|
||||||
{ RT2860_BKOFF_SLOT_CFG, 0x00000209 }, \
|
{ RT2860_BKOFF_SLOT_CFG, 0x00000209 }, \
|
||||||
{ RT2860_TX_SW_CFG0, 0x00000000 }, \
|
{ RT2860_TX_SW_CFG0, 0x00000000 }, \
|
||||||
{ RT2860_TX_SW_CFG1, 0x00080606 }, \
|
{ RT2860_TX_SW_CFG1, 0x00080606 }, \
|
||||||
{ RT2860_TX_LINK_CFG, 0x00001020 }, \
|
{ RT2860_TX_LINK_CFG, 0x00001020 }, \
|
||||||
{ RT2860_TX_TIMEOUT_CFG, 0x000a2090 }, \
|
{ RT2860_TX_TIMEOUT_CFG, 0x000a2090 }, \
|
||||||
|
{ RT2860_MAX_LEN_CFG, 0x00001f00 }, \
|
||||||
{ RT2860_LED_CFG, 0x7f031e46 }, \
|
{ RT2860_LED_CFG, 0x7f031e46 }, \
|
||||||
{ RT2860_WMM_AIFSN_CFG, 0x00002273 }, \
|
{ RT2860_WMM_AIFSN_CFG, 0x00002273 }, \
|
||||||
{ RT2860_WMM_CWMIN_CFG, 0x00002344 }, \
|
{ RT2860_WMM_CWMIN_CFG, 0x00002344 }, \
|
||||||
@@ -1028,42 +1060,9 @@ static const struct rt2860_rate {
|
|||||||
{ RT2860_MM20_PROT_CFG, 0x01744004 }, \
|
{ RT2860_MM20_PROT_CFG, 0x01744004 }, \
|
||||||
{ RT2860_MM40_PROT_CFG, 0x03f54084 }, \
|
{ RT2860_MM40_PROT_CFG, 0x03f54084 }, \
|
||||||
{ RT2860_TXOP_CTRL_CFG, 0x0000583f }, \
|
{ RT2860_TXOP_CTRL_CFG, 0x0000583f }, \
|
||||||
{ RT2860_TXOP_HLDR_ET, 0x00000002 }, \
|
|
||||||
{ RT2860_TX_RTS_CFG, 0x00092b20 }, \
|
{ RT2860_TX_RTS_CFG, 0x00092b20 }, \
|
||||||
{ RT2860_EXP_ACK_TIME, 0x002400ca }, \
|
{ RT2860_EXP_ACK_TIME, 0x002400ca }, \
|
||||||
{ RT2860_XIFS_TIME_CFG, 0x33a41010 }, \
|
|
||||||
{ RT2860_PWR_PIN_CFG, 0x00000003 }
|
|
||||||
|
|
||||||
/* XXX only a few registers differ from above, try to merge? */
|
|
||||||
#define RT2870_DEF_MAC \
|
|
||||||
{ RT2860_BCN_OFFSET0, 0xf8f0e8e0 }, \
|
|
||||||
{ RT2860_LEGACY_BASIC_RATE, 0x0000013f }, \
|
|
||||||
{ RT2860_HT_BASIC_RATE, 0x00008003 }, \
|
|
||||||
{ RT2860_MAC_SYS_CTRL, 0x00000000 }, \
|
|
||||||
{ RT2860_BKOFF_SLOT_CFG, 0x00000209 }, \
|
|
||||||
{ RT2860_TX_SW_CFG0, 0x00000000 }, \
|
|
||||||
{ RT2860_TX_SW_CFG1, 0x00080606 }, \
|
|
||||||
{ RT2860_TX_LINK_CFG, 0x00001020 }, \
|
|
||||||
{ RT2860_TX_TIMEOUT_CFG, 0x000a2090 }, \
|
|
||||||
{ RT2860_LED_CFG, 0x7f031e46 }, \
|
|
||||||
{ RT2860_WMM_AIFSN_CFG, 0x00002273 }, \
|
|
||||||
{ RT2860_WMM_CWMIN_CFG, 0x00002344 }, \
|
|
||||||
{ RT2860_WMM_CWMAX_CFG, 0x000034aa }, \
|
|
||||||
{ RT2860_MAX_PCNT, 0x1f3fbf9f }, \
|
|
||||||
{ RT2860_TX_RTY_CFG, 0x47d01f0f }, \
|
|
||||||
{ RT2860_AUTO_RSP_CFG, 0x00000013 }, \
|
|
||||||
{ RT2860_CCK_PROT_CFG, 0x05740003 }, \
|
|
||||||
{ RT2860_OFDM_PROT_CFG, 0x05740003 }, \
|
|
||||||
{ RT2860_PBF_CFG, 0x00f40006 }, \
|
|
||||||
{ RT2860_WPDMA_GLO_CFG, 0x00000030 }, \
|
|
||||||
{ RT2860_GF20_PROT_CFG, 0x01744004 }, \
|
|
||||||
{ RT2860_GF40_PROT_CFG, 0x03f44084 }, \
|
|
||||||
{ RT2860_MM20_PROT_CFG, 0x01744004 }, \
|
|
||||||
{ RT2860_MM40_PROT_CFG, 0x03f44084 }, \
|
|
||||||
{ RT2860_TXOP_CTRL_CFG, 0x0000583f }, \
|
|
||||||
{ RT2860_TXOP_HLDR_ET, 0x00000002 }, \
|
{ RT2860_TXOP_HLDR_ET, 0x00000002 }, \
|
||||||
{ RT2860_TX_RTS_CFG, 0x00092b20 }, \
|
|
||||||
{ RT2860_EXP_ACK_TIME, 0x002400ca }, \
|
|
||||||
{ RT2860_XIFS_TIME_CFG, 0x33a41010 }, \
|
{ RT2860_XIFS_TIME_CFG, 0x33a41010 }, \
|
||||||
{ RT2860_PWR_PIN_CFG, 0x00000003 }
|
{ RT2860_PWR_PIN_CFG, 0x00000003 }
|
||||||
|
|
||||||
@@ -1073,6 +1072,7 @@ static const struct rt2860_rate {
|
|||||||
#define RT2860_DEF_BBP \
|
#define RT2860_DEF_BBP \
|
||||||
{ 65, 0x2c }, \
|
{ 65, 0x2c }, \
|
||||||
{ 66, 0x38 }, \
|
{ 66, 0x38 }, \
|
||||||
|
{ 68, 0x0b }, \
|
||||||
{ 69, 0x12 }, \
|
{ 69, 0x12 }, \
|
||||||
{ 70, 0x0a }, \
|
{ 70, 0x0a }, \
|
||||||
{ 73, 0x10 }, \
|
{ 73, 0x10 }, \
|
||||||
@@ -1087,6 +1087,30 @@ static const struct rt2860_rate {
|
|||||||
{ 105, 0x05 }, \
|
{ 105, 0x05 }, \
|
||||||
{ 106, 0x35 }
|
{ 106, 0x35 }
|
||||||
|
|
||||||
|
#define RT5390_DEF_BBP \
|
||||||
|
{ 31, 0x08 }, \
|
||||||
|
{ 65, 0x2c }, \
|
||||||
|
{ 66, 0x38 }, \
|
||||||
|
{ 68, 0x0b }, \
|
||||||
|
{ 69, 0x12 }, \
|
||||||
|
{ 70, 0x0a }, \
|
||||||
|
{ 73, 0x13 }, \
|
||||||
|
{ 75, 0x46 }, \
|
||||||
|
{ 76, 0x28 }, \
|
||||||
|
{ 77, 0x59 }, \
|
||||||
|
{ 81, 0x37 }, \
|
||||||
|
{ 82, 0x62 }, \
|
||||||
|
{ 83, 0x7a }, \
|
||||||
|
{ 84, 0x19 }, \
|
||||||
|
{ 86, 0x38 }, \
|
||||||
|
{ 91, 0x04 }, \
|
||||||
|
{ 92, 0x02 }, \
|
||||||
|
{ 103, 0xc0 }, \
|
||||||
|
{ 104, 0x92 }, \
|
||||||
|
{ 105, 0x3c }, \
|
||||||
|
{ 106, 0x03 }, \
|
||||||
|
{ 128, 0x12 }, \
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default settings for RF registers; values derived from the reference driver.
|
* Default settings for RF registers; values derived from the reference driver.
|
||||||
*/
|
*/
|
||||||
@@ -1204,7 +1228,7 @@ static const struct rt2860_rate {
|
|||||||
{ 4, 0x40 }, \
|
{ 4, 0x40 }, \
|
||||||
{ 5, 0x03 }, \
|
{ 5, 0x03 }, \
|
||||||
{ 6, 0x02 }, \
|
{ 6, 0x02 }, \
|
||||||
{ 7, 0x70 }, \
|
{ 7, 0x60 }, \
|
||||||
{ 9, 0x0f }, \
|
{ 9, 0x0f }, \
|
||||||
{ 10, 0x41 }, \
|
{ 10, 0x41 }, \
|
||||||
{ 11, 0x21 }, \
|
{ 11, 0x21 }, \
|
||||||
@@ -1218,38 +1242,125 @@ static const struct rt2860_rate {
|
|||||||
{ 20, 0xba }, \
|
{ 20, 0xba }, \
|
||||||
{ 21, 0xdb }, \
|
{ 21, 0xdb }, \
|
||||||
{ 24, 0x16 }, \
|
{ 24, 0x16 }, \
|
||||||
{ 25, 0x01 }, \
|
{ 25, 0x03 }, \
|
||||||
{ 29, 0x1f }
|
{ 29, 0x1f }
|
||||||
|
|
||||||
#define RT3572_DEF_RF \
|
#define RT5390_DEF_RF \
|
||||||
{ 0, 0x70 }, \
|
{ 1, 0x0f }, \
|
||||||
{ 1, 0x81 }, \
|
{ 2, 0x80 }, \
|
||||||
{ 2, 0xf1 }, \
|
{ 3, 0x88 }, \
|
||||||
{ 3, 0x02 }, \
|
{ 5, 0x10 }, \
|
||||||
{ 4, 0x4c }, \
|
{ 6, 0xe0 }, \
|
||||||
{ 5, 0x05 }, \
|
{ 7, 0x00 }, \
|
||||||
{ 6, 0x4a }, \
|
{ 10, 0x53 }, \
|
||||||
{ 7, 0xd8 }, \
|
{ 11, 0x4a }, \
|
||||||
{ 9, 0xc3 }, \
|
{ 12, 0x46 }, \
|
||||||
{ 10, 0xf1 }, \
|
{ 13, 0x9f }, \
|
||||||
{ 11, 0xb9 }, \
|
{ 14, 0x00 }, \
|
||||||
{ 12, 0x70 }, \
|
{ 15, 0x00 }, \
|
||||||
{ 13, 0x65 }, \
|
{ 16, 0x00 }, \
|
||||||
{ 14, 0xa0 }, \
|
{ 18, 0x03 }, \
|
||||||
{ 15, 0x53 }, \
|
{ 19, 0x00 }, \
|
||||||
{ 16, 0x4c }, \
|
{ 20, 0x00 }, \
|
||||||
{ 17, 0x23 }, \
|
{ 21, 0x00 }, \
|
||||||
{ 18, 0xac }, \
|
{ 22, 0x20 }, \
|
||||||
{ 19, 0x93 }, \
|
{ 23, 0x00 }, \
|
||||||
{ 20, 0xb3 }, \
|
{ 24, 0x00 }, \
|
||||||
{ 21, 0xd0 }, \
|
{ 25, 0x80 }, \
|
||||||
{ 22, 0x00 }, \
|
{ 26, 0x00 }, \
|
||||||
{ 23, 0x3c }, \
|
{ 27, 0x09 }, \
|
||||||
{ 24, 0x16 }, \
|
|
||||||
{ 25, 0x15 }, \
|
|
||||||
{ 26, 0x85 }, \
|
|
||||||
{ 27, 0x00 }, \
|
|
||||||
{ 28, 0x00 }, \
|
{ 28, 0x00 }, \
|
||||||
{ 29, 0x9b }, \
|
{ 29, 0x10 }, \
|
||||||
{ 30, 0x09 }, \
|
{ 30, 0x10 }, \
|
||||||
{ 31, 0x10 }
|
{ 31, 0x80 }, \
|
||||||
|
{ 32, 0x80 }, \
|
||||||
|
{ 33, 0x00 }, \
|
||||||
|
{ 34, 0x07 }, \
|
||||||
|
{ 35, 0x12 }, \
|
||||||
|
{ 36, 0x00 }, \
|
||||||
|
{ 37, 0x08 }, \
|
||||||
|
{ 38, 0x85 }, \
|
||||||
|
{ 39, 0x1b }, \
|
||||||
|
{ 40, 0x0b }, \
|
||||||
|
{ 41, 0xbb }, \
|
||||||
|
{ 42, 0xd2 }, \
|
||||||
|
{ 43, 0x9a }, \
|
||||||
|
{ 44, 0x0e }, \
|
||||||
|
{ 45, 0xa2 }, \
|
||||||
|
{ 46, 0x73 }, \
|
||||||
|
{ 47, 0x00 }, \
|
||||||
|
{ 48, 0x10 }, \
|
||||||
|
{ 49, 0x94 }, \
|
||||||
|
{ 52, 0x38 }, \
|
||||||
|
{ 53, 0x00 }, \
|
||||||
|
{ 54, 0x78 }, \
|
||||||
|
{ 55, 0x23 }, \
|
||||||
|
{ 56, 0x22 }, \
|
||||||
|
{ 57, 0x80 }, \
|
||||||
|
{ 58, 0x7f }, \
|
||||||
|
{ 59, 0x07 }, \
|
||||||
|
{ 60, 0x45 }, \
|
||||||
|
{ 61, 0xd1 }, \
|
||||||
|
{ 62, 0x00 }, \
|
||||||
|
{ 63, 0x00 }
|
||||||
|
|
||||||
|
#define RT5392_DEF_RF \
|
||||||
|
{ 1, 0x17 }, \
|
||||||
|
{ 2, 0x80 }, \
|
||||||
|
{ 3, 0x88 }, \
|
||||||
|
{ 5, 0x10 }, \
|
||||||
|
{ 6, 0xe0 }, \
|
||||||
|
{ 7, 0x00 }, \
|
||||||
|
{ 10, 0x53 }, \
|
||||||
|
{ 11, 0x4a }, \
|
||||||
|
{ 12, 0x46 }, \
|
||||||
|
{ 13, 0x9f }, \
|
||||||
|
{ 14, 0x00 }, \
|
||||||
|
{ 15, 0x00 }, \
|
||||||
|
{ 16, 0x00 }, \
|
||||||
|
{ 18, 0x03 }, \
|
||||||
|
{ 19, 0x4d }, \
|
||||||
|
{ 20, 0x00 }, \
|
||||||
|
{ 21, 0x8d }, \
|
||||||
|
{ 22, 0x20 }, \
|
||||||
|
{ 23, 0x0b }, \
|
||||||
|
{ 24, 0x44 }, \
|
||||||
|
{ 25, 0x80 }, \
|
||||||
|
{ 26, 0x82 }, \
|
||||||
|
{ 27, 0x09 }, \
|
||||||
|
{ 28, 0x00 }, \
|
||||||
|
{ 29, 0x10 }, \
|
||||||
|
{ 30, 0x10 }, \
|
||||||
|
{ 31, 0x80 }, \
|
||||||
|
{ 32, 0x80 }, \
|
||||||
|
{ 33, 0xc0 }, \
|
||||||
|
{ 34, 0x07 }, \
|
||||||
|
{ 35, 0x12 }, \
|
||||||
|
{ 36, 0x00 }, \
|
||||||
|
{ 37, 0x08 }, \
|
||||||
|
{ 38, 0x89 }, \
|
||||||
|
{ 39, 0x1b }, \
|
||||||
|
{ 40, 0x0f }, \
|
||||||
|
{ 41, 0xbb }, \
|
||||||
|
{ 42, 0xd5 }, \
|
||||||
|
{ 43, 0x9b }, \
|
||||||
|
{ 44, 0x0e }, \
|
||||||
|
{ 45, 0xa2 }, \
|
||||||
|
{ 46, 0x73 }, \
|
||||||
|
{ 47, 0x0c }, \
|
||||||
|
{ 48, 0x10 }, \
|
||||||
|
{ 49, 0x94 }, \
|
||||||
|
{ 50, 0x94 }, \
|
||||||
|
{ 51, 0x3a }, \
|
||||||
|
{ 52, 0x48 }, \
|
||||||
|
{ 53, 0x44 }, \
|
||||||
|
{ 54, 0x38 }, \
|
||||||
|
{ 55, 0x43 }, \
|
||||||
|
{ 56, 0xa1 }, \
|
||||||
|
{ 57, 0x00 }, \
|
||||||
|
{ 58, 0x39 }, \
|
||||||
|
{ 59, 0x07 }, \
|
||||||
|
{ 60, 0x45 }, \
|
||||||
|
{ 61, 0x91 }, \
|
||||||
|
{ 62, 0x39 }, \
|
||||||
|
{ 63, 0x00 }
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: rt2860var.h,v 1.20 2010/09/07 16:21:42 deraadt Exp $
|
* $OpenBSD: rt2860var.h,v 1.20 2010/09/07 16:21:42 deraadt Exp $
|
||||||
* $FreeBSD$
|
* $FreeBSD: releng/11.1/sys/dev/ral/rt2860var.h 300657 2016-05-25 06:29:23Z sgalabov $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define RT2860_TX_RING_COUNT 64
|
#define RT2860_TX_RING_COUNT 64
|
||||||
@@ -38,7 +38,7 @@ struct rt2860_rx_radiotap_header {
|
|||||||
uint8_t wr_antenna;
|
uint8_t wr_antenna;
|
||||||
int8_t wr_antsignal;
|
int8_t wr_antsignal;
|
||||||
int8_t wr_antnoise;
|
int8_t wr_antnoise;
|
||||||
} __packed;
|
} __packed __aligned(8);
|
||||||
|
|
||||||
#define RT2860_RX_RADIOTAP_PRESENT \
|
#define RT2860_RX_RADIOTAP_PRESENT \
|
||||||
((1 << IEEE80211_RADIOTAP_TSFT) | \
|
((1 << IEEE80211_RADIOTAP_TSFT) | \
|
||||||
@@ -55,7 +55,7 @@ struct rt2860_tx_radiotap_header {
|
|||||||
uint8_t wt_rate;
|
uint8_t wt_rate;
|
||||||
uint16_t wt_chan_freq;
|
uint16_t wt_chan_freq;
|
||||||
uint16_t wt_chan_flags;
|
uint16_t wt_chan_flags;
|
||||||
} __packed;
|
} __packed __aligned(8);
|
||||||
|
|
||||||
#define RT2860_TX_RADIOTAP_PRESENT \
|
#define RT2860_TX_RADIOTAP_PRESENT \
|
||||||
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||||
@@ -115,13 +115,13 @@ struct rt2860_vap {
|
|||||||
#define RT2860_VAP(vap) ((struct rt2860_vap *)(vap))
|
#define RT2860_VAP(vap) ((struct rt2860_vap *)(vap))
|
||||||
|
|
||||||
struct rt2860_softc {
|
struct rt2860_softc {
|
||||||
struct ifnet *sc_ifp;
|
struct ieee80211com sc_ic;
|
||||||
|
struct mbufq sc_snd;
|
||||||
|
struct mtx sc_mtx;
|
||||||
device_t sc_dev;
|
device_t sc_dev;
|
||||||
bus_space_tag_t sc_st;
|
bus_space_tag_t sc_st;
|
||||||
bus_space_handle_t sc_sh;
|
bus_space_handle_t sc_sh;
|
||||||
|
|
||||||
struct mtx sc_mtx;
|
|
||||||
|
|
||||||
struct callout watchdog_ch;
|
struct callout watchdog_ch;
|
||||||
|
|
||||||
int sc_invalid;
|
int sc_invalid;
|
||||||
@@ -139,6 +139,7 @@ struct rt2860_softc {
|
|||||||
#define RT2860_ENABLED (1 << 0)
|
#define RT2860_ENABLED (1 << 0)
|
||||||
#define RT2860_ADVANCED_PS (1 << 1)
|
#define RT2860_ADVANCED_PS (1 << 1)
|
||||||
#define RT2860_PCIE (1 << 2)
|
#define RT2860_PCIE (1 << 2)
|
||||||
|
#define RT2860_RUNNING (1 << 3)
|
||||||
|
|
||||||
struct ieee80211_node *wcid2ni[RT2860_WCID_MAX];
|
struct ieee80211_node *wcid2ni[RT2860_WCID_MAX];
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ struct rt2860_softc {
|
|||||||
|
|
||||||
uint16_t mac_ver;
|
uint16_t mac_ver;
|
||||||
uint16_t mac_rev;
|
uint16_t mac_rev;
|
||||||
uint8_t rf_rev;
|
uint16_t rf_rev;
|
||||||
uint8_t freq;
|
uint8_t freq;
|
||||||
uint8_t ntxchains;
|
uint8_t ntxchains;
|
||||||
uint8_t nrxchains;
|
uint8_t nrxchains;
|
||||||
@@ -193,9 +194,7 @@ struct rt2860_softc {
|
|||||||
uint32_t txpow40mhz_5ghz[5];
|
uint32_t txpow40mhz_5ghz[5];
|
||||||
|
|
||||||
struct rt2860_rx_radiotap_header sc_rxtap;
|
struct rt2860_rx_radiotap_header sc_rxtap;
|
||||||
int sc_rxtap_len;
|
|
||||||
struct rt2860_tx_radiotap_header sc_txtap;
|
struct rt2860_tx_radiotap_header sc_txtap;
|
||||||
int sc_txtap_len;
|
|
||||||
|
|
||||||
#if defined(__HAIKU__)
|
#if defined(__HAIKU__)
|
||||||
uint32_t sc_intr_status;
|
uint32_t sc_intr_status;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <dev/ral/rt2560reg.h>
|
#include <dev/ral/rt2560reg.h>
|
||||||
#include <dev/ral/rt2560var.h>
|
#include <dev/ral/rt2560var.h>
|
||||||
|
#include <dev/ral/rt2661var.h>
|
||||||
#include <dev/ral/rt2860reg.h>
|
#include <dev/ral/rt2860reg.h>
|
||||||
#include <dev/ral/rt2860var.h>
|
#include <dev/ral/rt2860var.h>
|
||||||
|
|
||||||
@@ -26,9 +27,12 @@
|
|||||||
HAIKU_FBSD_WLAN_DRIVER_GLUE(ralinkwifi, ral, pci)
|
HAIKU_FBSD_WLAN_DRIVER_GLUE(ralinkwifi, ral, pci)
|
||||||
HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_SWI_TASKQUEUE | FBSD_WLAN);
|
HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_SWI_TASKQUEUE | FBSD_WLAN);
|
||||||
HAIKU_FIRMWARE_VERSION(0);
|
HAIKU_FIRMWARE_VERSION(0);
|
||||||
HAIKU_FIRMWARE_NAME_MAP(4) = {{"rt2561fw", "rt2561.bin"},
|
HAIKU_FIRMWARE_NAME_MAP(4) = {
|
||||||
{"rt2561sfw", "rt2561s.bin"}, {"rt2661fw", "rt2661.bin"},
|
{"rt2561fw", "rt2561.bin"},
|
||||||
{"rt2860fw", "rt2860.bin"}};
|
{"rt2561sfw", "rt2561s.bin"},
|
||||||
|
{"rt2661fw", "rt2661.bin"},
|
||||||
|
{"rt2860fw", "rt2860.bin"}
|
||||||
|
};
|
||||||
|
|
||||||
NO_HAIKU_FBSD_MII_DRIVER();
|
NO_HAIKU_FBSD_MII_DRIVER();
|
||||||
NO_HAIKU_REENABLE_INTERRUPTS();
|
NO_HAIKU_REENABLE_INTERRUPTS();
|
||||||
@@ -43,14 +47,13 @@ HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
|
|||||||
{
|
{
|
||||||
struct rt2560_softc* sc = (struct rt2560_softc*)device_get_softc(dev);
|
struct rt2560_softc* sc = (struct rt2560_softc*)device_get_softc(dev);
|
||||||
// sc_ifp is common between context data structures
|
// sc_ifp is common between context data structures
|
||||||
struct ifnet* ifp = sc->sc_ifp;
|
|
||||||
|
|
||||||
switch (pci_get_device(dev)) {
|
switch (pci_get_device(dev)) {
|
||||||
case 0x0201:
|
case 0x0201:
|
||||||
// disable interrupts
|
// disable interrupts
|
||||||
RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
|
RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
|
||||||
|
|
||||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
if (!(sc->sc_flags & RT2560_F_RUNNING)) {
|
||||||
// don't re-enable interrupts if we're shutting down
|
// don't re-enable interrupts if we're shutting down
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -62,7 +65,7 @@ HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
|
|||||||
RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0xffffff7f);
|
RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0xffffff7f);
|
||||||
RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff);
|
RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff);
|
||||||
|
|
||||||
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
if (!(sc->sc_flags & RAL_RUNNING)) {
|
||||||
// don't re-enable interrupts if we're shutting down
|
// don't re-enable interrupts if we're shutting down
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user