2005-04-18 18:47:38 +00:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
|
|
|
|
/*-
|
2006-01-29 12:35:26 +00:00
|
|
|
* Copyright (c) 2005, 2006
|
2005-04-18 18:47:38 +00:00
|
|
|
* Damien Bergamini <damien.bergamini@free.fr>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
/*-
|
2006-03-05 20:36:56 +00:00
|
|
|
* Ralink Technology RT2560 chipset driver
|
2005-04-18 18:47:38 +00:00
|
|
|
* http://www.ralinktech.com/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
2006-12-07 15:24:38 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
2005-04-18 18:47:38 +00:00
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/endian.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2005-04-18 18:47:38 +00:00
|
|
|
#include <net/if_arp.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
|
|
|
#include <net80211/ieee80211_radiotap.h>
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
#include <net80211/ieee80211_regdomain.h>
|
2010-04-07 15:29:13 +00:00
|
|
|
#include <net80211/ieee80211_ratectl.h>
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
|
2006-03-05 23:27:51 +00:00
|
|
|
#include <dev/ral/rt2560reg.h>
|
|
|
|
#include <dev/ral/rt2560var.h>
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
#define RT2560_RSSI(sc, rssi) \
|
|
|
|
((rssi) > (RT2560_NOISE_FLOOR + (sc)->rssi_corr) ? \
|
|
|
|
((rssi) - RT2560_NOISE_FLOOR - (sc)->rssi_corr) : 0)
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
#define RAL_DEBUG
|
2005-04-18 18:47:38 +00:00
|
|
|
#ifdef RAL_DEBUG
|
2008-04-20 20:35:46 +00:00
|
|
|
#define DPRINTF(sc, fmt, ...) do { \
|
|
|
|
if (sc->sc_debug > 0) \
|
|
|
|
printf(fmt, __VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
#define DPRINTFN(sc, n, fmt, ...) do { \
|
|
|
|
if (sc->sc_debug >= (n)) \
|
|
|
|
printf(fmt, __VA_ARGS__); \
|
|
|
|
} while (0)
|
2005-04-18 18:47:38 +00:00
|
|
|
#else
|
2008-04-20 20:35:46 +00:00
|
|
|
#define DPRINTF(sc, fmt, ...)
|
|
|
|
#define DPRINTFN(sc, n, fmt, ...)
|
2005-04-18 18:47:38 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static struct ieee80211vap *rt2560_vap_create(struct ieee80211com *,
|
2011-12-17 10:23:17 +00:00
|
|
|
const char [IFNAMSIZ], int, enum ieee80211_opmode,
|
|
|
|
int, const uint8_t [IEEE80211_ADDR_LEN],
|
|
|
|
const uint8_t [IEEE80211_ADDR_LEN]);
|
2008-04-20 20:35:46 +00:00
|
|
|
static void rt2560_vap_delete(struct ieee80211vap *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_dma_map_addr(void *, bus_dma_segment_t *, int,
|
|
|
|
int);
|
|
|
|
static int rt2560_alloc_tx_ring(struct rt2560_softc *,
|
|
|
|
struct rt2560_tx_ring *, int);
|
|
|
|
static void rt2560_reset_tx_ring(struct rt2560_softc *,
|
|
|
|
struct rt2560_tx_ring *);
|
|
|
|
static void rt2560_free_tx_ring(struct rt2560_softc *,
|
|
|
|
struct rt2560_tx_ring *);
|
|
|
|
static int rt2560_alloc_rx_ring(struct rt2560_softc *,
|
|
|
|
struct rt2560_rx_ring *, int);
|
|
|
|
static void rt2560_reset_rx_ring(struct rt2560_softc *,
|
|
|
|
struct rt2560_rx_ring *);
|
|
|
|
static void rt2560_free_rx_ring(struct rt2560_softc *,
|
|
|
|
struct rt2560_rx_ring *);
|
2008-04-20 20:35:46 +00:00
|
|
|
static int rt2560_newstate(struct ieee80211vap *,
|
2005-04-18 18:47:38 +00:00
|
|
|
enum ieee80211_state, int);
|
2006-03-05 20:36:56 +00:00
|
|
|
static uint16_t rt2560_eeprom_read(struct rt2560_softc *, uint8_t);
|
|
|
|
static void rt2560_encryption_intr(struct rt2560_softc *);
|
|
|
|
static void rt2560_tx_intr(struct rt2560_softc *);
|
|
|
|
static void rt2560_prio_intr(struct rt2560_softc *);
|
|
|
|
static void rt2560_decryption_intr(struct rt2560_softc *);
|
|
|
|
static void rt2560_rx_intr(struct rt2560_softc *);
|
2008-04-20 20:35:46 +00:00
|
|
|
static void rt2560_beacon_update(struct ieee80211vap *, int item);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_beacon_expire(struct rt2560_softc *);
|
|
|
|
static void rt2560_wakeup_expire(struct rt2560_softc *);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
static void rt2560_scan_start(struct ieee80211com *);
|
|
|
|
static void rt2560_scan_end(struct ieee80211com *);
|
|
|
|
static void rt2560_set_channel(struct ieee80211com *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_setup_tx_desc(struct rt2560_softc *,
|
|
|
|
struct rt2560_tx_desc *, uint32_t, int, int, int,
|
2005-04-18 18:47:38 +00:00
|
|
|
bus_addr_t);
|
2006-03-05 20:36:56 +00:00
|
|
|
static int rt2560_tx_bcn(struct rt2560_softc *, struct mbuf *,
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_node *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static int rt2560_tx_mgt(struct rt2560_softc *, struct mbuf *,
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_node *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static int rt2560_tx_data(struct rt2560_softc *, struct mbuf *,
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_node *);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
static int rt2560_transmit(struct ieee80211com *, struct mbuf *);
|
|
|
|
static void rt2560_start(struct rt2560_softc *);
|
2006-12-19 17:37:41 +00:00
|
|
|
static void rt2560_watchdog(void *);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
static void rt2560_parent(struct ieee80211com *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_bbp_write(struct rt2560_softc *, uint8_t,
|
|
|
|
uint8_t);
|
|
|
|
static uint8_t rt2560_bbp_read(struct rt2560_softc *, uint8_t);
|
|
|
|
static void rt2560_rf_write(struct rt2560_softc *, uint8_t,
|
|
|
|
uint32_t);
|
|
|
|
static void rt2560_set_chan(struct rt2560_softc *,
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_channel *);
|
|
|
|
#if 0
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_disable_rf_tune(struct rt2560_softc *);
|
2005-04-18 18:47:38 +00:00
|
|
|
#endif
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_enable_tsf_sync(struct rt2560_softc *);
|
2009-05-20 20:00:40 +00:00
|
|
|
static void rt2560_enable_tsf(struct rt2560_softc *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_update_plcp(struct rt2560_softc *);
|
2015-05-25 19:53:29 +00:00
|
|
|
static void rt2560_update_slot(struct ieee80211com *);
|
2011-04-09 14:45:50 +00:00
|
|
|
static void rt2560_set_basicrates(struct rt2560_softc *,
|
|
|
|
const struct ieee80211_rateset *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_update_led(struct rt2560_softc *, int, int);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
static void rt2560_set_bssid(struct rt2560_softc *, const uint8_t *);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
static void rt2560_set_macaddr(struct rt2560_softc *,
|
|
|
|
const uint8_t *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_get_macaddr(struct rt2560_softc *, uint8_t *);
|
2015-05-25 19:53:29 +00:00
|
|
|
static void rt2560_update_promisc(struct ieee80211com *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static const char *rt2560_get_rf(int);
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
static void rt2560_read_config(struct rt2560_softc *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static int rt2560_bbp_init(struct rt2560_softc *);
|
|
|
|
static void rt2560_set_txantenna(struct rt2560_softc *, int);
|
|
|
|
static void rt2560_set_rxantenna(struct rt2560_softc *, int);
|
2008-04-20 20:35:46 +00:00
|
|
|
static void rt2560_init_locked(struct rt2560_softc *);
|
2006-03-05 20:36:56 +00:00
|
|
|
static void rt2560_init(void *);
|
2008-04-20 20:35:46 +00:00
|
|
|
static void rt2560_stop_locked(struct rt2560_softc *);
|
2006-07-26 03:30:50 +00:00
|
|
|
static int rt2560_raw_xmit(struct ieee80211_node *, struct mbuf *,
|
|
|
|
const struct ieee80211_bpf_params *);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
static const struct {
|
|
|
|
uint32_t reg;
|
|
|
|
uint32_t val;
|
2006-03-05 20:36:56 +00:00
|
|
|
} rt2560_def_mac[] = {
|
|
|
|
RT2560_DEF_MAC
|
2005-04-18 18:47:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
uint8_t reg;
|
|
|
|
uint8_t val;
|
2006-03-05 20:36:56 +00:00
|
|
|
} rt2560_def_bbp[] = {
|
|
|
|
RT2560_DEF_BBP
|
2005-04-18 18:47:38 +00:00
|
|
|
};
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
static const uint32_t rt2560_rf2522_r2[] = RT2560_RF2522_R2;
|
|
|
|
static const uint32_t rt2560_rf2523_r2[] = RT2560_RF2523_R2;
|
|
|
|
static const uint32_t rt2560_rf2524_r2[] = RT2560_RF2524_R2;
|
|
|
|
static const uint32_t rt2560_rf2525_r2[] = RT2560_RF2525_R2;
|
|
|
|
static const uint32_t rt2560_rf2525_hi_r2[] = RT2560_RF2525_HI_R2;
|
|
|
|
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_hi_r2[] = RT2560_RF2526_HI_R2;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
static const struct {
|
|
|
|
uint8_t chan;
|
2006-03-05 20:36:56 +00:00
|
|
|
uint32_t r1, r2, r4;
|
|
|
|
} rt2560_rf5222[] = {
|
|
|
|
RT2560_RF5222
|
2005-04-18 18:47:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_attach(device_t dev, int id)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_softc *sc = device_get_softc(dev);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2016-01-07 18:41:03 +00:00
|
|
|
uint8_t bands[howmany(IEEE80211_MODE_MAX, 8)];
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
int error;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sc->sc_dev = dev;
|
|
|
|
|
|
|
|
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
|
|
|
|
MTX_DEF | MTX_RECURSE);
|
|
|
|
|
2006-12-19 17:37:41 +00:00
|
|
|
callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
mbufq_init(&sc->sc_snd, ifqmaxlen);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* retrieve RT2560 rev. no */
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->asic_rev = RAL_READ(sc, RT2560_CSR0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* retrieve RF rev. no and various other things from EEPROM */
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
rt2560_read_config(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
device_printf(dev, "MAC/BBP RT2560 (rev 0x%02x), RF %s\n",
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->asic_rev, rt2560_get_rf(sc->rf_rev));
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate Tx and Rx rings.
|
|
|
|
*/
|
2006-03-05 20:36:56 +00:00
|
|
|
error = rt2560_alloc_tx_ring(sc, &sc->txq, RT2560_TX_RING_COUNT);
|
|
|
|
if (error != 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not allocate Tx ring\n");
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
error = rt2560_alloc_tx_ring(sc, &sc->atimq, RT2560_ATIM_RING_COUNT);
|
|
|
|
if (error != 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not allocate ATIM ring\n");
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
error = rt2560_alloc_tx_ring(sc, &sc->prioq, RT2560_PRIO_RING_COUNT);
|
|
|
|
if (error != 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not allocate Prio ring\n");
|
|
|
|
goto fail3;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
error = rt2560_alloc_tx_ring(sc, &sc->bcnq, RT2560_BEACON_RING_COUNT);
|
|
|
|
if (error != 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not allocate Beacon ring\n");
|
|
|
|
goto fail4;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
error = rt2560_alloc_rx_ring(sc, &sc->rxq, RT2560_RX_RING_COUNT);
|
|
|
|
if (error != 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not allocate Rx ring\n");
|
|
|
|
goto fail5;
|
|
|
|
}
|
2006-03-05 20:36:56 +00:00
|
|
|
|
2015-08-08 01:10:17 +00:00
|
|
|
/* retrieve MAC address */
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
rt2560_get_macaddr(sc, ic->ic_macaddr);
|
|
|
|
|
2015-05-25 18:50:26 +00:00
|
|
|
ic->ic_softc = sc;
|
2015-05-25 13:51:13 +00:00
|
|
|
ic->ic_name = device_get_nameunit(dev);
|
2008-04-20 20:35:46 +00:00
|
|
|
ic->ic_opmode = IEEE80211_M_STA;
|
2005-04-18 18:47:38 +00:00
|
|
|
ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
|
|
|
|
|
|
|
|
/* set device capabilities */
|
2005-11-29 21:30:16 +00:00
|
|
|
ic->ic_caps =
|
2008-05-12 00:15:30 +00:00
|
|
|
IEEE80211_C_STA /* station mode */
|
|
|
|
| IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
|
2008-04-20 20:35:46 +00:00
|
|
|
| IEEE80211_C_HOSTAP /* hostap mode */
|
|
|
|
| IEEE80211_C_MONITOR /* monitor mode */
|
|
|
|
| IEEE80211_C_AHDEMO /* adhoc demo mode */
|
|
|
|
| IEEE80211_C_WDS /* 4-address traffic works */
|
Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.
Authentication and encryption are not implemented.
There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).
A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.
Drivers that support mesh networks right now are: ath, ral and mwl.
More information at: http://wiki.freebsd.org/WifiMesh
Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.
Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.
Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s
2009-07-11 15:02:45 +00:00
|
|
|
| IEEE80211_C_MBSS /* mesh point link mode */
|
2008-04-20 20:35:46 +00:00
|
|
|
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
|
|
|
|
| IEEE80211_C_SHSLOT /* short slot time supported */
|
|
|
|
| IEEE80211_C_WPA /* capable of WPA1+WPA2 */
|
|
|
|
| IEEE80211_C_BGSCAN /* capable of bg scanning */
|
|
|
|
#ifdef notyet
|
|
|
|
| IEEE80211_C_TXFRAG /* handle tx frags */
|
|
|
|
#endif
|
|
|
|
;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2016-01-07 18:41:03 +00:00
|
|
|
memset(bands, 0, sizeof(bands));
|
|
|
|
setbit(bands, IEEE80211_MODE_11B);
|
|
|
|
setbit(bands, IEEE80211_MODE_11G);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
if (sc->rf_rev == RT2560_RF_5222)
|
2016-01-07 18:41:03 +00:00
|
|
|
setbit(bands, IEEE80211_MODE_11A);
|
|
|
|
ieee80211_init_channels(ic, NULL, bands);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ieee80211_ifattach(ic);
|
2008-04-20 20:35:46 +00:00
|
|
|
ic->ic_raw_xmit = rt2560_raw_xmit;
|
|
|
|
ic->ic_updateslot = rt2560_update_slot;
|
|
|
|
ic->ic_update_promisc = rt2560_update_promisc;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
ic->ic_scan_start = rt2560_scan_start;
|
|
|
|
ic->ic_scan_end = rt2560_scan_end;
|
|
|
|
ic->ic_set_channel = rt2560_set_channel;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
ic->ic_vap_create = rt2560_vap_create;
|
|
|
|
ic->ic_vap_delete = rt2560_vap_delete;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ic->ic_parent = rt2560_parent;
|
|
|
|
ic->ic_transmit = rt2560_transmit;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_attach(ic,
|
|
|
|
&sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap),
|
|
|
|
RT2560_TX_RADIOTAP_PRESENT,
|
|
|
|
&sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
|
|
|
|
RT2560_RX_RADIOTAP_PRESENT);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a few sysctl knobs.
|
|
|
|
*/
|
2008-04-20 20:35:46 +00:00
|
|
|
#ifdef RAL_DEBUG
|
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
|
|
|
|
"debug", CTLFLAG_RW, &sc->sc_debug, 0, "debug msgs");
|
|
|
|
#endif
|
2005-04-18 18:47:38 +00:00
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
|
|
|
|
"txantenna", CTLFLAG_RW, &sc->tx_ant, 0, "tx antenna (0=auto)");
|
|
|
|
|
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
|
|
|
|
"rxantenna", CTLFLAG_RW, &sc->rx_ant, 0, "rx antenna (0=auto)");
|
|
|
|
|
|
|
|
if (bootverbose)
|
|
|
|
ieee80211_announce(ic);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
fail5: rt2560_free_tx_ring(sc, &sc->bcnq);
|
|
|
|
fail4: rt2560_free_tx_ring(sc, &sc->prioq);
|
|
|
|
fail3: rt2560_free_tx_ring(sc, &sc->atimq);
|
|
|
|
fail2: rt2560_free_tx_ring(sc, &sc->txq);
|
2005-04-18 18:47:38 +00:00
|
|
|
fail1: mtx_destroy(&sc->sc_mtx);
|
|
|
|
|
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_detach(void *xsc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_softc *sc = xsc;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_stop(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
ieee80211_ifdetach(ic);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
mbufq_drain(&sc->sc_snd);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_free_tx_ring(sc, &sc->txq);
|
|
|
|
rt2560_free_tx_ring(sc, &sc->atimq);
|
|
|
|
rt2560_free_tx_ring(sc, &sc->prioq);
|
|
|
|
rt2560_free_tx_ring(sc, &sc->bcnq);
|
|
|
|
rt2560_free_rx_ring(sc, &sc->rxq);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
mtx_destroy(&sc->sc_mtx);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static struct ieee80211vap *
|
2011-12-17 10:23:17 +00:00
|
|
|
rt2560_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
|
|
|
|
enum ieee80211_opmode opmode, int flags,
|
|
|
|
const uint8_t bssid[IEEE80211_ADDR_LEN],
|
|
|
|
const uint8_t mac[IEEE80211_ADDR_LEN])
|
2008-04-20 20:35:46 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct rt2560_vap *rvp;
|
|
|
|
struct ieee80211vap *vap;
|
|
|
|
|
|
|
|
switch (opmode) {
|
|
|
|
case IEEE80211_M_STA:
|
|
|
|
case IEEE80211_M_IBSS:
|
|
|
|
case IEEE80211_M_AHDEMO:
|
|
|
|
case IEEE80211_M_MONITOR:
|
|
|
|
case IEEE80211_M_HOSTAP:
|
Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.
Authentication and encryption are not implemented.
There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).
A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.
Drivers that support mesh networks right now are: ath, ral and mwl.
More information at: http://wiki.freebsd.org/WifiMesh
Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.
Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.
Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s
2009-07-11 15:02:45 +00:00
|
|
|
case IEEE80211_M_MBSS:
|
|
|
|
/* XXXRP: TBD */
|
2008-04-20 20:35:46 +00:00
|
|
|
if (!TAILQ_EMPTY(&ic->ic_vaps)) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
device_printf(sc->sc_dev, "only 1 vap supported\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (opmode == IEEE80211_M_STA)
|
|
|
|
flags |= IEEE80211_CLONE_NOBEACONS;
|
|
|
|
break;
|
|
|
|
case IEEE80211_M_WDS:
|
|
|
|
if (TAILQ_EMPTY(&ic->ic_vaps) ||
|
|
|
|
ic->ic_opmode != IEEE80211_M_HOSTAP) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"wds only supported in ap mode\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Silently remove any request for a unique
|
|
|
|
* bssid; WDS vap's always share the local
|
|
|
|
* mac address.
|
|
|
|
*/
|
|
|
|
flags &= ~IEEE80211_CLONE_BSSID;
|
|
|
|
break;
|
|
|
|
default:
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
device_printf(sc->sc_dev, "unknown opmode %d\n", opmode);
|
2008-04-20 20:35:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
rvp = malloc(sizeof(struct rt2560_vap), M_80211_VAP, M_WAITOK | M_ZERO);
|
2008-04-20 20:35:46 +00:00
|
|
|
vap = &rvp->ral_vap;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid);
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
/* override state transition machine */
|
|
|
|
rvp->ral_newstate = vap->iv_newstate;
|
|
|
|
vap->iv_newstate = rt2560_newstate;
|
|
|
|
vap->iv_update_beacon = rt2560_beacon_update;
|
|
|
|
|
2010-04-07 15:29:13 +00:00
|
|
|
ieee80211_ratectl_init(vap);
|
2008-04-20 20:35:46 +00:00
|
|
|
/* complete setup */
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
ieee80211_vap_attach(vap, ieee80211_media_change,
|
|
|
|
ieee80211_media_status, mac);
|
2008-04-20 20:35:46 +00:00
|
|
|
if (TAILQ_FIRST(&ic->ic_vaps) == vap)
|
|
|
|
ic->ic_opmode = opmode;
|
|
|
|
return vap;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rt2560_vap_delete(struct ieee80211vap *vap)
|
|
|
|
{
|
|
|
|
struct rt2560_vap *rvp = RT2560_VAP(vap);
|
|
|
|
|
2010-04-07 15:29:13 +00:00
|
|
|
ieee80211_ratectl_deinit(vap);
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_vap_detach(vap);
|
|
|
|
free(rvp, M_80211_VAP);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_resume(void *xsc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_softc *sc = xsc;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (sc->sc_ic.ic_nrunning > 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
rt2560_init(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
if (error != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
|
|
|
|
|
|
|
|
*(bus_addr_t *)arg = segs[0].ds_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_alloc_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring,
|
|
|
|
int count)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
int i, error;
|
|
|
|
|
|
|
|
ring->count = count;
|
|
|
|
ring->queued = 0;
|
|
|
|
ring->cur = ring->next = 0;
|
|
|
|
ring->cur_encrypt = ring->next_encrypt = 0;
|
|
|
|
|
2007-07-22 06:44:10 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
count * RT2560_TX_DESC_SIZE, 1, count * RT2560_TX_DESC_SIZE,
|
|
|
|
0, NULL, NULL, &ring->desc_dmat);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create desc DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc,
|
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not allocate DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc,
|
2006-03-05 20:36:56 +00:00
|
|
|
count * RT2560_TX_DESC_SIZE, rt2560_dma_map_addr, &ring->physaddr,
|
|
|
|
0);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not load desc DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
ring->data = malloc(count * sizeof (struct rt2560_tx_data), M_DEVBUF,
|
2005-04-18 18:47:38 +00:00
|
|
|
M_NOWAIT | M_ZERO);
|
|
|
|
if (ring->data == NULL) {
|
|
|
|
device_printf(sc->sc_dev, "could not allocate soft data\n");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2007-07-22 06:44:10 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
MCLBYTES, RT2560_MAX_SCATTER, MCLBYTES, 0, NULL, NULL,
|
|
|
|
&ring->data_dmat);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create data DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
error = bus_dmamap_create(ring->data_dmat, 0,
|
|
|
|
&ring->data[i].map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
fail: rt2560_free_tx_ring(sc, ring);
|
2005-04-18 18:47:38 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_reset_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ring->count; i++) {
|
|
|
|
desc = &ring->desc[i];
|
|
|
|
data = &ring->data[i];
|
|
|
|
|
|
|
|
if (data->m != NULL) {
|
|
|
|
bus_dmamap_sync(ring->data_dmat, data->map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(ring->data_dmat, data->map);
|
|
|
|
m_freem(data->m);
|
|
|
|
data->m = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->ni != NULL) {
|
|
|
|
ieee80211_free_node(data->ni);
|
|
|
|
data->ni = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
desc->flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
ring->queued = 0;
|
|
|
|
ring->cur = ring->next = 0;
|
|
|
|
ring->cur_encrypt = ring->next_encrypt = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_free_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ring->desc != NULL) {
|
|
|
|
bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(ring->desc_dmat, ring->desc_map);
|
|
|
|
bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ring->desc_dmat != NULL)
|
|
|
|
bus_dma_tag_destroy(ring->desc_dmat);
|
|
|
|
|
|
|
|
if (ring->data != NULL) {
|
|
|
|
for (i = 0; i < ring->count; i++) {
|
|
|
|
data = &ring->data[i];
|
|
|
|
|
|
|
|
if (data->m != NULL) {
|
|
|
|
bus_dmamap_sync(ring->data_dmat, data->map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(ring->data_dmat, data->map);
|
|
|
|
m_freem(data->m);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->ni != NULL)
|
|
|
|
ieee80211_free_node(data->ni);
|
|
|
|
|
|
|
|
if (data->map != NULL)
|
|
|
|
bus_dmamap_destroy(ring->data_dmat, data->map);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ring->data, M_DEVBUF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ring->data_dmat != NULL)
|
|
|
|
bus_dma_tag_destroy(ring->data_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_alloc_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring,
|
|
|
|
int count)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_rx_desc *desc;
|
|
|
|
struct rt2560_rx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
bus_addr_t physaddr;
|
|
|
|
int i, error;
|
|
|
|
|
|
|
|
ring->count = count;
|
|
|
|
ring->cur = ring->next = 0;
|
|
|
|
ring->cur_decrypt = 0;
|
|
|
|
|
2007-07-22 06:44:10 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
count * RT2560_RX_DESC_SIZE, 1, count * RT2560_RX_DESC_SIZE,
|
|
|
|
0, NULL, NULL, &ring->desc_dmat);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create desc DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc,
|
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not allocate DMA memory\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc,
|
2006-03-05 20:36:56 +00:00
|
|
|
count * RT2560_RX_DESC_SIZE, rt2560_dma_map_addr, &ring->physaddr,
|
|
|
|
0);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not load desc DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
ring->data = malloc(count * sizeof (struct rt2560_rx_data), M_DEVBUF,
|
2005-04-18 18:47:38 +00:00
|
|
|
M_NOWAIT | M_ZERO);
|
|
|
|
if (ring->data == NULL) {
|
|
|
|
device_printf(sc->sc_dev, "could not allocate soft data\n");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pre-allocate Rx buffers and populate Rx ring.
|
|
|
|
*/
|
2007-07-22 06:44:10 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES,
|
|
|
|
1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create data DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
desc = &sc->rxq.desc[i];
|
|
|
|
data = &sc->rxq.data[i];
|
|
|
|
|
|
|
|
error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not create DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2012-12-04 09:32:43 +00:00
|
|
|
data->m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (data->m == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate rx mbuf\n");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamap_load(ring->data_dmat, data->map,
|
2006-03-05 20:36:56 +00:00
|
|
|
mtod(data->m, void *), MCLBYTES, rt2560_dma_map_addr,
|
2005-04-18 18:47:38 +00:00
|
|
|
&physaddr, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not load rx buf DMA map");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
desc->flags = htole32(RT2560_RX_BUSY);
|
2005-04-18 18:47:38 +00:00
|
|
|
desc->physaddr = htole32(physaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
fail: rt2560_free_rx_ring(sc, ring);
|
2005-04-18 18:47:38 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_reset_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ring->count; i++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
ring->desc[i].flags = htole32(RT2560_RX_BUSY);
|
2005-04-18 18:47:38 +00:00
|
|
|
ring->data[i].drop = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
ring->cur = ring->next = 0;
|
|
|
|
ring->cur_decrypt = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_free_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_rx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ring->desc != NULL) {
|
|
|
|
bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(ring->desc_dmat, ring->desc_map);
|
|
|
|
bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ring->desc_dmat != NULL)
|
|
|
|
bus_dma_tag_destroy(ring->desc_dmat);
|
|
|
|
|
|
|
|
if (ring->data != NULL) {
|
|
|
|
for (i = 0; i < ring->count; i++) {
|
|
|
|
data = &ring->data[i];
|
|
|
|
|
|
|
|
if (data->m != NULL) {
|
|
|
|
bus_dmamap_sync(ring->data_dmat, data->map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
bus_dmamap_unload(ring->data_dmat, data->map);
|
|
|
|
m_freem(data->m);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->map != NULL)
|
|
|
|
bus_dmamap_destroy(ring->data_dmat, data->map);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ring->data, M_DEVBUF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ring->data_dmat != NULL)
|
|
|
|
bus_dma_tag_destroy(ring->data_dmat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-04-20 20:35:46 +00:00
|
|
|
rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct rt2560_vap *rvp = RT2560_VAP(vap);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct rt2560_softc *sc = vap->iv_ic->ic_softc;
|
2008-04-20 20:35:46 +00:00
|
|
|
int error;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
|
|
|
|
/* abort TSF synchronization */
|
|
|
|
RAL_WRITE(sc, RT2560_CSR14, 0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
/* turn association led off */
|
|
|
|
rt2560_update_led(sc, 0, 0);
|
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
error = rvp->ral_newstate(vap, nstate, arg);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (error == 0 && nstate == IEEE80211_S_RUN) {
|
|
|
|
struct ieee80211_node *ni = vap->iv_bss;
|
|
|
|
struct mbuf *m;
|
2005-08-21 14:16:20 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (vap->iv_opmode != IEEE80211_M_MONITOR) {
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_update_plcp(sc);
|
2011-04-09 14:45:50 +00:00
|
|
|
rt2560_set_basicrates(sc, &ni->ni_rates);
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_set_bssid(sc, ni->ni_bssid);
|
2006-01-29 12:35:26 +00:00
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
|
Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.
Authentication and encryption are not implemented.
There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).
A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.
Drivers that support mesh networks right now are: ath, ral and mwl.
More information at: http://wiki.freebsd.org/WifiMesh
Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.
Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.
Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s
2009-07-11 15:02:45 +00:00
|
|
|
vap->iv_opmode == IEEE80211_M_IBSS ||
|
|
|
|
vap->iv_opmode == IEEE80211_M_MBSS) {
|
2015-10-03 22:12:25 +00:00
|
|
|
m = ieee80211_beacon_alloc(ni);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (m == NULL) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate beacon\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
return ENOBUFS;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
2006-01-29 12:35:26 +00:00
|
|
|
ieee80211_ref_node(ni);
|
2006-03-05 20:36:56 +00:00
|
|
|
error = rt2560_tx_bcn(sc, m, ni);
|
2005-04-18 18:47:38 +00:00
|
|
|
if (error != 0)
|
2008-04-20 20:35:46 +00:00
|
|
|
return error;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* turn assocation led on */
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_update_led(sc, 1, 0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-10-27 16:46:50 +00:00
|
|
|
if (vap->iv_opmode != IEEE80211_M_MONITOR)
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_enable_tsf_sync(sc);
|
2009-05-20 20:00:40 +00:00
|
|
|
else
|
|
|
|
rt2560_enable_tsf(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
return error;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read 16 bits at address 'addr' from the serial EEPROM (either 93C46 or
|
|
|
|
* 93C66).
|
|
|
|
*/
|
|
|
|
static uint16_t
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_eeprom_read(struct rt2560_softc *sc, uint8_t addr)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
uint16_t val;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* clock C once before the first command */
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, 0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S);
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C);
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* write start bit (1) */
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D);
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D | RT2560_C);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* write READ opcode (10) */
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D);
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D | RT2560_C);
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S);
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* write address (A5-A0 or A7-A0) */
|
2006-03-05 20:36:56 +00:00
|
|
|
n = (RAL_READ(sc, RT2560_CSR21) & RT2560_93C46) ? 5 : 7;
|
2005-04-18 18:47:38 +00:00
|
|
|
for (; n >= 0; n--) {
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S |
|
|
|
|
(((addr >> n) & 1) << RT2560_SHIFT_D));
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S |
|
|
|
|
(((addr >> n) & 1) << RT2560_SHIFT_D) | RT2560_C);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* read data Q15-Q0 */
|
|
|
|
val = 0;
|
|
|
|
for (n = 15; n >= 0; n--) {
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C);
|
|
|
|
tmp = RAL_READ(sc, RT2560_CSR21);
|
|
|
|
val |= ((tmp & RT2560_Q) >> RT2560_SHIFT_Q) << n;
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, 0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* clear Chip Select and clock C */
|
2006-03-05 20:36:56 +00:00
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_S);
|
|
|
|
RT2560_EEPROM_CTL(sc, 0);
|
|
|
|
RT2560_EEPROM_CTL(sc, RT2560_C);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-01-29 12:35:26 +00:00
|
|
|
return val;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some frames were processed by the hardware cipher engine and are ready for
|
|
|
|
* transmission.
|
|
|
|
*/
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_encryption_intr(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
2005-04-18 18:47:38 +00:00
|
|
|
int hw;
|
|
|
|
|
|
|
|
/* retrieve last descriptor index processed by cipher engine */
|
2006-03-05 20:36:56 +00:00
|
|
|
hw = RAL_READ(sc, RT2560_SECCSR1) - sc->txq.physaddr;
|
|
|
|
hw /= RT2560_TX_DESC_SIZE;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
while (sc->txq.next_encrypt != hw) {
|
|
|
|
if (sc->txq.next_encrypt == sc->txq.cur_encrypt) {
|
|
|
|
printf("hw encrypt %d, cur_encrypt %d\n", hw,
|
|
|
|
sc->txq.cur_encrypt);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
desc = &sc->txq.desc[sc->txq.next_encrypt];
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if ((le32toh(desc->flags) & RT2560_TX_BUSY) ||
|
|
|
|
(le32toh(desc->flags) & RT2560_TX_CIPHER_BUSY))
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* for TKIP, swap eiv field to fix a bug in ASIC */
|
2006-03-05 20:36:56 +00:00
|
|
|
if ((le32toh(desc->flags) & RT2560_TX_CIPHER_MASK) ==
|
|
|
|
RT2560_TX_CIPHER_TKIP)
|
2005-04-18 18:47:38 +00:00
|
|
|
desc->eiv = bswap32(desc->eiv);
|
|
|
|
|
|
|
|
/* mark the frame ready for transmission */
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
desc->flags |= htole32(RT2560_TX_VALID);
|
|
|
|
desc->flags |= htole32(RT2560_TX_BUSY);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "encryption done idx=%u\n",
|
|
|
|
sc->txq.next_encrypt);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sc->txq.next_encrypt =
|
2006-03-05 20:36:56 +00:00
|
|
|
(sc->txq.next_encrypt + 1) % RT2560_TX_RING_COUNT;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
/* kick Tx */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_TXCSR0, RT2560_KICK_TX);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_tx_intr(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct mbuf *m;
|
2010-04-07 15:29:13 +00:00
|
|
|
struct ieee80211vap *vap;
|
|
|
|
struct ieee80211_node *ni;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
uint32_t flags;
|
|
|
|
int retrycnt, status;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
desc = &sc->txq.desc[sc->txq.next];
|
|
|
|
data = &sc->txq.data[sc->txq.next];
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
flags = le32toh(desc->flags);
|
|
|
|
if ((flags & RT2560_TX_BUSY) ||
|
|
|
|
(flags & RT2560_TX_CIPHER_BUSY) ||
|
|
|
|
!(flags & RT2560_TX_VALID))
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
m = data->m;
|
2010-04-07 15:29:13 +00:00
|
|
|
ni = data->ni;
|
|
|
|
vap = ni->ni_vap;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
switch (flags & RT2560_TX_RESULT_MASK) {
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_SUCCESS:
|
2010-04-07 15:29:13 +00:00
|
|
|
retrycnt = 0;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 10, "%s\n", "data frame sent successfully");
|
|
|
|
if (data->rix != IEEE80211_FIXED_RATE_NONE)
|
2010-04-07 15:29:13 +00:00
|
|
|
ieee80211_ratectl_tx_complete(vap, ni,
|
|
|
|
IEEE80211_RATECTL_TX_SUCCESS,
|
|
|
|
&retrycnt, NULL);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
status = 0;
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_SUCCESS_RETRY:
|
2008-04-20 20:35:46 +00:00
|
|
|
retrycnt = RT2560_TX_RETRYCNT(flags);
|
|
|
|
|
|
|
|
DPRINTFN(sc, 9, "data frame sent after %u retries\n",
|
|
|
|
retrycnt);
|
|
|
|
if (data->rix != IEEE80211_FIXED_RATE_NONE)
|
2010-04-07 15:29:13 +00:00
|
|
|
ieee80211_ratectl_tx_complete(vap, ni,
|
|
|
|
IEEE80211_RATECTL_TX_SUCCESS,
|
|
|
|
&retrycnt, NULL);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
status = 0;
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_FAIL_RETRY:
|
2008-04-20 20:35:46 +00:00
|
|
|
retrycnt = RT2560_TX_RETRYCNT(flags);
|
|
|
|
|
|
|
|
DPRINTFN(sc, 9, "data frame failed after %d retries\n",
|
|
|
|
retrycnt);
|
|
|
|
if (data->rix != IEEE80211_FIXED_RATE_NONE)
|
2010-04-07 15:29:13 +00:00
|
|
|
ieee80211_ratectl_tx_complete(vap, ni,
|
|
|
|
IEEE80211_RATECTL_TX_FAILURE,
|
|
|
|
&retrycnt, NULL);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
status = 1;
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_FAIL_INVALID:
|
|
|
|
case RT2560_TX_FAIL_OTHER:
|
2005-04-18 18:47:38 +00:00
|
|
|
default:
|
|
|
|
device_printf(sc->sc_dev, "sending data frame failed "
|
2008-04-20 20:35:46 +00:00
|
|
|
"0x%08x\n", flags);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
status = 1;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->txq.data_dmat, data->map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(sc->txq.data_dmat, data->map);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
|
|
|
|
ieee80211_tx_complete(ni, m, status);
|
2015-08-08 01:10:17 +00:00
|
|
|
data->ni = NULL;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
data->m = NULL;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* descriptor is no longer valid */
|
2006-03-05 20:36:56 +00:00
|
|
|
desc->flags &= ~htole32(RT2560_TX_VALID);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "tx done idx=%u\n", sc->txq.next);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sc->txq.queued--;
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->txq.next = (sc->txq.next + 1) % RT2560_TX_RING_COUNT;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
if (sc->prioq.queued == 0 && sc->txq.queued == 0)
|
|
|
|
sc->sc_tx_timer = 0;
|
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (sc->txq.queued < RT2560_TX_RING_COUNT - 1)
|
|
|
|
rt2560_start(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_prio_intr(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
struct ieee80211_node *ni;
|
|
|
|
struct mbuf *m;
|
|
|
|
int flags;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->prioq.desc_dmat, sc->prioq.desc_map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
desc = &sc->prioq.desc[sc->prioq.next];
|
|
|
|
data = &sc->prioq.data[sc->prioq.next];
|
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
flags = le32toh(desc->flags);
|
|
|
|
if ((flags & RT2560_TX_BUSY) || (flags & RT2560_TX_VALID) == 0)
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
switch (flags & RT2560_TX_RESULT_MASK) {
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_SUCCESS:
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 10, "%s\n", "mgt frame sent successfully");
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_SUCCESS_RETRY:
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 9, "mgt frame sent after %u retries\n",
|
|
|
|
(flags >> 5) & 0x7);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_FAIL_RETRY:
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 9, "%s\n",
|
|
|
|
"sending mgt frame failed (too much retries)");
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_TX_FAIL_INVALID:
|
|
|
|
case RT2560_TX_FAIL_OTHER:
|
2005-04-18 18:47:38 +00:00
|
|
|
default:
|
|
|
|
device_printf(sc->sc_dev, "sending mgt frame failed "
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
"0x%08x\n", flags);
|
|
|
|
break;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->prioq.data_dmat, data->map,
|
|
|
|
BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(sc->prioq.data_dmat, data->map);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
|
|
|
m = data->m;
|
2005-04-18 18:47:38 +00:00
|
|
|
data->m = NULL;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
ni = data->ni;
|
2005-04-18 18:47:38 +00:00
|
|
|
data->ni = NULL;
|
|
|
|
|
|
|
|
/* descriptor is no longer valid */
|
2006-03-05 20:36:56 +00:00
|
|
|
desc->flags &= ~htole32(RT2560_TX_VALID);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "prio done idx=%u\n", sc->prioq.next);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sc->prioq.queued--;
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->prioq.next = (sc->prioq.next + 1) % RT2560_PRIO_RING_COUNT;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
|
|
|
if (m->m_flags & M_TXCB)
|
|
|
|
ieee80211_process_callback(ni, m,
|
|
|
|
(flags & RT2560_TX_RESULT_MASK) &~
|
|
|
|
(RT2560_TX_SUCCESS | RT2560_TX_SUCCESS_RETRY));
|
|
|
|
m_freem(m);
|
|
|
|
ieee80211_free_node(ni);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->prioq.desc_dmat, sc->prioq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
if (sc->prioq.queued == 0 && sc->txq.queued == 0)
|
|
|
|
sc->sc_tx_timer = 0;
|
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (sc->prioq.queued < RT2560_PRIO_RING_COUNT)
|
|
|
|
rt2560_start(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some frames were processed by the hardware cipher engine and are ready for
|
2008-04-20 20:35:46 +00:00
|
|
|
* handoff to the IEEE802.11 layer.
|
2005-04-18 18:47:38 +00:00
|
|
|
*/
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_decryption_intr(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_rx_desc *desc;
|
|
|
|
struct rt2560_rx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
bus_addr_t physaddr;
|
|
|
|
struct ieee80211_frame *wh;
|
|
|
|
struct ieee80211_node *ni;
|
2005-11-13 17:19:12 +00:00
|
|
|
struct mbuf *mnew, *m;
|
2005-04-18 18:47:38 +00:00
|
|
|
int hw, error;
|
2009-05-20 20:00:40 +00:00
|
|
|
int8_t rssi, nf;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* retrieve last decriptor index processed by cipher engine */
|
2006-03-05 20:36:56 +00:00
|
|
|
hw = RAL_READ(sc, RT2560_SECCSR0) - sc->rxq.physaddr;
|
|
|
|
hw /= RT2560_RX_DESC_SIZE;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rxq.desc_dmat, sc->rxq.desc_map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
for (; sc->rxq.cur_decrypt != hw;) {
|
|
|
|
desc = &sc->rxq.desc[sc->rxq.cur_decrypt];
|
|
|
|
data = &sc->rxq.data[sc->rxq.cur_decrypt];
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if ((le32toh(desc->flags) & RT2560_RX_BUSY) ||
|
|
|
|
(le32toh(desc->flags) & RT2560_RX_CIPHER_BUSY))
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (data->drop) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
counter_u64_add(ic->ic_ierrors, 1);
|
2005-04-18 18:47:38 +00:00
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if ((le32toh(desc->flags) & RT2560_RX_CIPHER_MASK) != 0 &&
|
|
|
|
(le32toh(desc->flags) & RT2560_RX_ICV_ERROR)) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
counter_u64_add(ic->ic_ierrors, 1);
|
2005-04-18 18:47:38 +00:00
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
2005-11-13 17:19:12 +00:00
|
|
|
/*
|
|
|
|
* Try to allocate a new mbuf for this ring element and load it
|
|
|
|
* before processing the current mbuf. If the ring element
|
|
|
|
* cannot be loaded, drop the received packet and reuse the old
|
|
|
|
* mbuf. In the unlikely case that the old mbuf can't be
|
|
|
|
* reloaded either, explicitly panic.
|
|
|
|
*/
|
2012-12-04 09:32:43 +00:00
|
|
|
mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
2005-11-13 17:19:12 +00:00
|
|
|
if (mnew == NULL) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
counter_u64_add(ic->ic_ierrors, 1);
|
2005-11-13 17:19:12 +00:00
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
bus_dmamap_sync(sc->rxq.data_dmat, data->map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
bus_dmamap_unload(sc->rxq.data_dmat, data->map);
|
|
|
|
|
2005-11-13 17:19:12 +00:00
|
|
|
error = bus_dmamap_load(sc->rxq.data_dmat, data->map,
|
2006-03-05 20:36:56 +00:00
|
|
|
mtod(mnew, void *), MCLBYTES, rt2560_dma_map_addr,
|
|
|
|
&physaddr, 0);
|
2005-11-13 17:19:12 +00:00
|
|
|
if (error != 0) {
|
|
|
|
m_freem(mnew);
|
|
|
|
|
|
|
|
/* try to reload the old mbuf */
|
|
|
|
error = bus_dmamap_load(sc->rxq.data_dmat, data->map,
|
2006-03-05 20:36:56 +00:00
|
|
|
mtod(data->m, void *), MCLBYTES,
|
|
|
|
rt2560_dma_map_addr, &physaddr, 0);
|
2005-11-13 17:19:12 +00:00
|
|
|
if (error != 0) {
|
|
|
|
/* very unlikely that it will fail... */
|
|
|
|
panic("%s: could not load old rx mbuf",
|
|
|
|
device_get_name(sc->sc_dev));
|
|
|
|
}
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
counter_u64_add(ic->ic_ierrors, 1);
|
2005-11-13 17:19:12 +00:00
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* New mbuf successfully loaded, update Rx ring and continue
|
|
|
|
* processing.
|
|
|
|
*/
|
2005-04-18 18:47:38 +00:00
|
|
|
m = data->m;
|
2005-11-13 17:19:12 +00:00
|
|
|
data->m = mnew;
|
|
|
|
desc->physaddr = htole32(physaddr);
|
|
|
|
|
|
|
|
/* finalize mbuf */
|
2005-04-18 18:47:38 +00:00
|
|
|
m->m_pkthdr.len = m->m_len =
|
|
|
|
(le32toh(desc->flags) >> 16) & 0xfff;
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
rssi = RT2560_RSSI(sc, desc->rssi);
|
|
|
|
nf = RT2560_NOISE_FLOOR;
|
|
|
|
if (ieee80211_radiotap_active(ic)) {
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_rx_radiotap_header *tap = &sc->sc_rxtap;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint32_t tsf_lo, tsf_hi;
|
|
|
|
|
|
|
|
/* get timestamp (low and high 32 bits) */
|
2006-03-05 20:36:56 +00:00
|
|
|
tsf_hi = RAL_READ(sc, RT2560_CSR17);
|
|
|
|
tsf_lo = RAL_READ(sc, RT2560_CSR16);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
tap->wr_tsf =
|
|
|
|
htole64(((uint64_t)tsf_hi << 32) | tsf_lo);
|
|
|
|
tap->wr_flags = 0;
|
2008-04-20 20:35:46 +00:00
|
|
|
tap->wr_rate = ieee80211_plcp2rate(desc->rate,
|
2008-05-12 00:32:52 +00:00
|
|
|
(desc->flags & htole32(RT2560_RX_OFDM)) ?
|
|
|
|
IEEE80211_T_OFDM : IEEE80211_T_CCK);
|
2005-04-18 18:47:38 +00:00
|
|
|
tap->wr_antenna = sc->rx_ant;
|
2009-05-20 20:00:40 +00:00
|
|
|
tap->wr_antsignal = nf + rssi;
|
|
|
|
tap->wr_antnoise = nf;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
sc->sc_flags |= RT2560_F_INPUT_RUNNING;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
RAL_UNLOCK(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
wh = mtod(m, struct ieee80211_frame *);
|
|
|
|
ni = ieee80211_find_rxnode(ic,
|
|
|
|
(struct ieee80211_frame_min *)wh);
|
2008-04-20 20:35:46 +00:00
|
|
|
if (ni != NULL) {
|
2009-05-20 20:00:40 +00:00
|
|
|
(void) ieee80211_input(ni, m, rssi, nf);
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_free_node(ni);
|
|
|
|
} else
|
2009-05-20 20:00:40 +00:00
|
|
|
(void) ieee80211_input_all(ic, m, rssi, nf);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
RAL_LOCK(sc);
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
sc->sc_flags &= ~RT2560_F_INPUT_RUNNING;
|
2006-03-05 20:36:56 +00:00
|
|
|
skip: desc->flags = htole32(RT2560_RX_BUSY);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "decryption done idx=%u\n", sc->rxq.cur_decrypt);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
sc->rxq.cur_decrypt =
|
2006-03-05 20:36:56 +00:00
|
|
|
(sc->rxq.cur_decrypt + 1) % RT2560_RX_RING_COUNT;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rxq.desc_dmat, sc->rxq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some frames were received. Pass them to the hardware cipher engine before
|
|
|
|
* sending them to the 802.11 layer.
|
|
|
|
*/
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rx_intr(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_rx_desc *desc;
|
|
|
|
struct rt2560_rx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rxq.desc_dmat, sc->rxq.desc_map,
|
|
|
|
BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
desc = &sc->rxq.desc[sc->rxq.cur];
|
|
|
|
data = &sc->rxq.data[sc->rxq.cur];
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if ((le32toh(desc->flags) & RT2560_RX_BUSY) ||
|
|
|
|
(le32toh(desc->flags) & RT2560_RX_CIPHER_BUSY))
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
data->drop = 0;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if ((le32toh(desc->flags) & RT2560_RX_PHY_ERROR) ||
|
|
|
|
(le32toh(desc->flags) & RT2560_RX_CRC_ERROR)) {
|
2005-04-18 18:47:38 +00:00
|
|
|
/*
|
|
|
|
* This should not happen since we did not request
|
|
|
|
* to receive those frames when we filled RXCSR0.
|
|
|
|
*/
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 5, "PHY or CRC error flags 0x%08x\n",
|
|
|
|
le32toh(desc->flags));
|
2005-04-18 18:47:38 +00:00
|
|
|
data->drop = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((le32toh(desc->flags) >> 16) & 0xfff) > MCLBYTES) {
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 5, "%s\n", "bad length");
|
2005-04-18 18:47:38 +00:00
|
|
|
data->drop = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mark the frame for decryption */
|
2006-03-05 20:36:56 +00:00
|
|
|
desc->flags |= htole32(RT2560_RX_CIPHER_BUSY);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "rx done idx=%u\n", sc->rxq.cur);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->rxq.cur = (sc->rxq.cur + 1) % RT2560_RX_RING_COUNT;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->rxq.desc_dmat, sc->rxq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
/* kick decrypt */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_SECCSR0, RT2560_KICK_DECRYPT);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 19:07:24 +00:00
|
|
|
static void
|
2008-04-20 20:35:46 +00:00
|
|
|
rt2560_beacon_update(struct ieee80211vap *vap, int item)
|
2007-09-17 19:07:24 +00:00
|
|
|
{
|
2015-09-22 06:34:07 +00:00
|
|
|
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
|
2007-09-17 19:07:24 +00:00
|
|
|
|
|
|
|
setbit(bo->bo_flags, item);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/*
|
|
|
|
* This function is called periodically in IBSS mode when a new beacon must be
|
|
|
|
* sent out.
|
|
|
|
*/
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_beacon_expire(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
if (ic->ic_opmode != IEEE80211_M_IBSS &&
|
Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.
Authentication and encryption are not implemented.
There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).
A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.
Drivers that support mesh networks right now are: ath, ral and mwl.
More information at: http://wiki.freebsd.org/WifiMesh
Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.
Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.
Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s
2009-07-11 15:02:45 +00:00
|
|
|
ic->ic_opmode != IEEE80211_M_HOSTAP &&
|
|
|
|
ic->ic_opmode != IEEE80211_M_MBSS)
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
return;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
data = &sc->bcnq.data[sc->bcnq.next];
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
/*
|
|
|
|
* Don't send beacon if bsschan isn't set
|
|
|
|
*/
|
|
|
|
if (data->ni == NULL)
|
|
|
|
return;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->bcnq.data_dmat, data->map, BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(sc->bcnq.data_dmat, data->map);
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX 1 =>'s mcast frames which means all PS sta's will wakeup! */
|
2015-10-03 22:12:25 +00:00
|
|
|
ieee80211_beacon_update(data->ni, data->m, 1);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_tx_bcn(sc, data->m, data->ni);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "%s", "beacon expired\n");
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->bcnq.next = (sc->bcnq.next + 1) % RT2560_BEACON_RING_COUNT;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
/* ARGSUSED */
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_wakeup_expire(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 2, "%s", "wakeup expired\n");
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
void
|
|
|
|
rt2560_intr(void *arg)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_softc *sc = arg;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint32_t r;
|
|
|
|
|
|
|
|
RAL_LOCK(sc);
|
|
|
|
|
|
|
|
/* disable interrupts */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-21 21:15:43 +00:00
|
|
|
/* don't re-enable interrupts if we're shutting down */
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (!(sc->sc_flags & RT2560_F_RUNNING)) {
|
2006-03-21 21:15:43 +00:00
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
r = RAL_READ(sc, RT2560_CSR7);
|
|
|
|
RAL_WRITE(sc, RT2560_CSR7, r);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (r & RT2560_BEACON_EXPIRE)
|
|
|
|
rt2560_beacon_expire(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (r & RT2560_WAKEUP_EXPIRE)
|
|
|
|
rt2560_wakeup_expire(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (r & RT2560_ENCRYPTION_DONE)
|
|
|
|
rt2560_encryption_intr(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (r & RT2560_TX_DONE)
|
|
|
|
rt2560_tx_intr(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (r & RT2560_PRIO_DONE)
|
|
|
|
rt2560_prio_intr(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (r & RT2560_DECRYPTION_DONE)
|
|
|
|
rt2560_decryption_intr(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
if (r & RT2560_RX_DONE) {
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rx_intr(sc);
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
rt2560_encryption_intr(sc);
|
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* re-enable interrupts */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
2005-08-21 14:16:20 +00:00
|
|
|
#define RAL_SIFS 10 /* us */
|
2006-01-29 12:35:26 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
#define RT2560_TXRX_TURNAROUND 10 /* us */
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-05-12 00:32:52 +00:00
|
|
|
static uint8_t
|
|
|
|
rt2560_plcp_signal(int rate)
|
|
|
|
{
|
|
|
|
switch (rate) {
|
|
|
|
/* OFDM rates (cf IEEE Std 802.11a-1999, pp. 14 Table 80) */
|
|
|
|
case 12: return 0xb;
|
|
|
|
case 18: return 0xf;
|
|
|
|
case 24: return 0xa;
|
|
|
|
case 36: return 0xe;
|
|
|
|
case 48: return 0x9;
|
|
|
|
case 72: return 0xd;
|
|
|
|
case 96: return 0x8;
|
|
|
|
case 108: return 0xc;
|
|
|
|
|
|
|
|
/* CCK rates (NB: not IEEE std, device-specific) */
|
|
|
|
case 2: return 0x0;
|
|
|
|
case 4: return 0x1;
|
|
|
|
case 11: return 0x2;
|
|
|
|
case 22: return 0x3;
|
|
|
|
}
|
|
|
|
return 0xff; /* XXX unsupported/unknown rate */
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_setup_tx_desc(struct rt2560_softc *sc, struct rt2560_tx_desc *desc,
|
2005-04-18 18:47:38 +00:00
|
|
|
uint32_t flags, int len, int rate, int encrypt, bus_addr_t physaddr)
|
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint16_t plcp_length;
|
|
|
|
int remainder;
|
|
|
|
|
|
|
|
desc->flags = htole32(flags);
|
|
|
|
desc->flags |= htole32(len << 16);
|
|
|
|
|
|
|
|
desc->physaddr = htole32(physaddr);
|
2006-03-05 20:36:56 +00:00
|
|
|
desc->wme = htole16(
|
|
|
|
RT2560_AIFSN(2) |
|
|
|
|
RT2560_LOGCWMIN(3) |
|
|
|
|
RT2560_LOGCWMAX(8));
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-01-29 12:35:26 +00:00
|
|
|
/* setup PLCP fields */
|
2008-05-12 00:32:52 +00:00
|
|
|
desc->plcp_signal = rt2560_plcp_signal(rate);
|
2005-04-18 18:47:38 +00:00
|
|
|
desc->plcp_service = 4;
|
|
|
|
|
2006-01-29 12:35:26 +00:00
|
|
|
len += IEEE80211_CRC_LEN;
|
2009-03-29 21:17:08 +00:00
|
|
|
if (ieee80211_rate2phytype(ic->ic_rt, rate) == IEEE80211_T_OFDM) {
|
2006-03-05 20:36:56 +00:00
|
|
|
desc->flags |= htole32(RT2560_TX_OFDM);
|
2006-01-29 12:35:26 +00:00
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
plcp_length = len & 0xfff;
|
2005-11-29 21:30:16 +00:00
|
|
|
desc->plcp_length_hi = plcp_length >> 6;
|
|
|
|
desc->plcp_length_lo = plcp_length & 0x3f;
|
2005-04-18 18:47:38 +00:00
|
|
|
} else {
|
2005-11-23 17:32:57 +00:00
|
|
|
plcp_length = (16 * len + rate - 1) / rate;
|
|
|
|
if (rate == 22) {
|
|
|
|
remainder = (16 * len) % 22;
|
|
|
|
if (remainder != 0 && remainder < 7)
|
2006-03-05 20:36:56 +00:00
|
|
|
desc->plcp_service |= RT2560_PLCP_LENGEXT;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
2005-11-29 21:30:16 +00:00
|
|
|
desc->plcp_length_hi = plcp_length >> 8;
|
|
|
|
desc->plcp_length_lo = plcp_length & 0xff;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-01-29 12:35:26 +00:00
|
|
|
if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
|
|
|
|
desc->plcp_signal |= 0x08;
|
|
|
|
}
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
|
|
|
|
if (!encrypt)
|
|
|
|
desc->flags |= htole32(RT2560_TX_VALID);
|
|
|
|
desc->flags |= encrypt ? htole32(RT2560_TX_CIPHER_BUSY)
|
|
|
|
: htole32(RT2560_TX_BUSY);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_tx_bcn(struct rt2560_softc *sc, struct mbuf *m0,
|
|
|
|
struct ieee80211_node *ni)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
|
|
|
bus_dma_segment_t segs[RT2560_MAX_SCATTER];
|
2005-04-18 18:47:38 +00:00
|
|
|
int nsegs, rate, error;
|
|
|
|
|
|
|
|
desc = &sc->bcnq.desc[sc->bcnq.cur];
|
|
|
|
data = &sc->bcnq.data[sc->bcnq.cur];
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX maybe a separate beacon rate? */
|
|
|
|
rate = vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)].mgmtrate;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->bcnq.data_dmat, data->map, m0,
|
|
|
|
segs, &nsegs, BUS_DMA_NOWAIT);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not map mbuf (error %d)\n",
|
|
|
|
error);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
if (ieee80211_radiotap_active_vap(vap)) {
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_radiotap_header *tap = &sc->sc_txtap;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
tap->wt_flags = 0;
|
|
|
|
tap->wt_rate = rate;
|
|
|
|
tap->wt_antenna = sc->tx_ant;
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_tx(vap, m0);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data->m = m0;
|
|
|
|
data->ni = ni;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_setup_tx_desc(sc, desc, RT2560_TX_IFS_NEWBACKOFF |
|
|
|
|
RT2560_TX_TIMESTAMP, m0->m_pkthdr.len, rate, 0, segs->ds_addr);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 10, "sending beacon frame len=%u idx=%u rate=%u\n",
|
|
|
|
m0->m_pkthdr.len, sc->bcnq.cur, rate);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
bus_dmamap_sync(sc->bcnq.data_dmat, data->map, BUS_DMASYNC_PREWRITE);
|
|
|
|
bus_dmamap_sync(sc->bcnq.desc_dmat, sc->bcnq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->bcnq.cur = (sc->bcnq.cur + 1) % RT2560_BEACON_RING_COUNT;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0,
|
|
|
|
struct ieee80211_node *ni)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ieee80211com *ic = ni->ni_ic;
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_frame *wh;
|
2007-11-06 07:30:12 +00:00
|
|
|
struct ieee80211_key *k;
|
2006-03-05 20:36:56 +00:00
|
|
|
bus_dma_segment_t segs[RT2560_MAX_SCATTER];
|
2005-04-18 18:47:38 +00:00
|
|
|
uint16_t dur;
|
|
|
|
uint32_t flags = 0;
|
|
|
|
int nsegs, rate, error;
|
|
|
|
|
|
|
|
desc = &sc->prioq.desc[sc->prioq.cur];
|
|
|
|
data = &sc->prioq.data[sc->prioq.cur];
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2007-11-06 07:30:12 +00:00
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
|
2014-01-08 08:06:56 +00:00
|
|
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
2008-04-20 20:35:46 +00:00
|
|
|
k = ieee80211_crypto_encap(ni, m0);
|
2007-11-06 07:30:12 +00:00
|
|
|
if (k == NULL) {
|
|
|
|
m_freem(m0);
|
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->prioq.data_dmat, data->map, m0,
|
|
|
|
segs, &nsegs, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not map mbuf (error %d)\n",
|
|
|
|
error);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
if (ieee80211_radiotap_active_vap(vap)) {
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_radiotap_header *tap = &sc->sc_txtap;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
tap->wt_flags = 0;
|
|
|
|
tap->wt_rate = rate;
|
|
|
|
tap->wt_antenna = sc->tx_ant;
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_tx(vap, m0);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data->m = m0;
|
|
|
|
data->ni = ni;
|
2008-04-20 20:35:46 +00:00
|
|
|
/* management frames are not taken into account for amrr */
|
|
|
|
data->rix = IEEE80211_FIXED_RATE_NONE;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
|
|
|
|
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
|
2006-03-05 20:36:56 +00:00
|
|
|
flags |= RT2560_TX_ACK;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2009-03-29 21:17:08 +00:00
|
|
|
dur = ieee80211_ack_duration(ic->ic_rt,
|
2008-04-20 20:35:46 +00:00
|
|
|
rate, ic->ic_flags & IEEE80211_F_SHPREAMBLE);
|
2005-04-18 18:47:38 +00:00
|
|
|
*(uint16_t *)wh->i_dur = htole16(dur);
|
|
|
|
|
|
|
|
/* tell hardware to add timestamp for probe responses */
|
|
|
|
if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
|
|
|
|
IEEE80211_FC0_TYPE_MGT &&
|
|
|
|
(wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) ==
|
|
|
|
IEEE80211_FC0_SUBTYPE_PROBE_RESP)
|
2006-03-05 20:36:56 +00:00
|
|
|
flags |= RT2560_TX_TIMESTAMP;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_setup_tx_desc(sc, desc, flags, m0->m_pkthdr.len, rate, 0,
|
2005-04-18 18:47:38 +00:00
|
|
|
segs->ds_addr);
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->prioq.data_dmat, data->map, BUS_DMASYNC_PREWRITE);
|
|
|
|
bus_dmamap_sync(sc->prioq.desc_dmat, sc->prioq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 10, "sending mgt frame len=%u idx=%u rate=%u\n",
|
|
|
|
m0->m_pkthdr.len, sc->prioq.cur, rate);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* kick prio */
|
|
|
|
sc->prioq.queued++;
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->prioq.cur = (sc->prioq.cur + 1) % RT2560_PRIO_RING_COUNT;
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR0, RT2560_KICK_PRIO);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static int
|
|
|
|
rt2560_sendprot(struct rt2560_softc *sc,
|
|
|
|
const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = ni->ni_ic;
|
|
|
|
const struct ieee80211_frame *wh;
|
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
|
|
|
struct mbuf *mprot;
|
|
|
|
int protrate, ackrate, pktlen, flags, isshort, error;
|
|
|
|
uint16_t dur;
|
|
|
|
bus_dma_segment_t segs[RT2560_MAX_SCATTER];
|
|
|
|
int nsegs;
|
|
|
|
|
|
|
|
KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY,
|
|
|
|
("protection %d", prot));
|
|
|
|
|
|
|
|
wh = mtod(m, const struct ieee80211_frame *);
|
|
|
|
pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN;
|
|
|
|
|
2009-03-29 21:17:08 +00:00
|
|
|
protrate = ieee80211_ctl_rate(ic->ic_rt, rate);
|
|
|
|
ackrate = ieee80211_ack_rate(ic->ic_rt, rate);
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
isshort = (ic->ic_flags & IEEE80211_F_SHPREAMBLE) != 0;
|
2009-03-29 21:17:08 +00:00
|
|
|
dur = ieee80211_compute_duration(ic->ic_rt, pktlen, rate, isshort)
|
|
|
|
+ ieee80211_ack_duration(ic->ic_rt, rate, isshort);
|
2008-04-20 20:35:46 +00:00
|
|
|
flags = RT2560_TX_MORE_FRAG;
|
|
|
|
if (prot == IEEE80211_PROT_RTSCTS) {
|
|
|
|
/* NB: CTS is the same size as an ACK */
|
2009-03-29 21:17:08 +00:00
|
|
|
dur += ieee80211_ack_duration(ic->ic_rt, rate, isshort);
|
2008-04-20 20:35:46 +00:00
|
|
|
flags |= RT2560_TX_ACK;
|
|
|
|
mprot = ieee80211_alloc_rts(ic, wh->i_addr1, wh->i_addr2, dur);
|
|
|
|
} else {
|
|
|
|
mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur);
|
|
|
|
}
|
|
|
|
if (mprot == NULL) {
|
|
|
|
/* XXX stat + msg */
|
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
desc = &sc->txq.desc[sc->txq.cur_encrypt];
|
|
|
|
data = &sc->txq.data[sc->txq.cur_encrypt];
|
|
|
|
|
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->txq.data_dmat, data->map,
|
|
|
|
mprot, segs, &nsegs, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not map mbuf (error %d)\n", error);
|
|
|
|
m_freem(mprot);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->m = mprot;
|
|
|
|
data->ni = ieee80211_ref_node(ni);
|
|
|
|
/* ctl frames are not taken into account for amrr */
|
|
|
|
data->rix = IEEE80211_FIXED_RATE_NONE;
|
|
|
|
|
|
|
|
rt2560_setup_tx_desc(sc, desc, flags, mprot->m_pkthdr.len, protrate, 1,
|
|
|
|
segs->ds_addr);
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->txq.data_dmat, data->map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
sc->txq.queued++;
|
|
|
|
sc->txq.cur_encrypt = (sc->txq.cur_encrypt + 1) % RT2560_TX_RING_COUNT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-26 03:30:50 +00:00
|
|
|
static int
|
|
|
|
rt2560_tx_raw(struct rt2560_softc *sc, struct mbuf *m0,
|
|
|
|
struct ieee80211_node *ni, const struct ieee80211_bpf_params *params)
|
|
|
|
{
|
2009-05-20 20:00:40 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
2009-05-29 23:41:31 +00:00
|
|
|
struct ieee80211com *ic = ni->ni_ic;
|
2006-07-26 03:30:50 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
|
|
|
bus_dma_segment_t segs[RT2560_MAX_SCATTER];
|
|
|
|
uint32_t flags;
|
|
|
|
int nsegs, rate, error;
|
|
|
|
|
|
|
|
desc = &sc->prioq.desc[sc->prioq.cur];
|
|
|
|
data = &sc->prioq.data[sc->prioq.cur];
|
|
|
|
|
2009-05-29 23:41:31 +00:00
|
|
|
rate = params->ibp_rate0;
|
|
|
|
if (!ieee80211_isratevalid(ic->ic_rt, rate)) {
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX fall back to mcast/mgmt rate? */
|
2007-04-19 13:09:57 +00:00
|
|
|
m_freem(m0);
|
2006-07-26 03:30:50 +00:00
|
|
|
return EINVAL;
|
2007-04-19 13:09:57 +00:00
|
|
|
}
|
2006-07-26 03:30:50 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
flags = 0;
|
|
|
|
if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0)
|
|
|
|
flags |= RT2560_TX_ACK;
|
|
|
|
if (params->ibp_flags & (IEEE80211_BPF_RTS|IEEE80211_BPF_CTS)) {
|
|
|
|
error = rt2560_sendprot(sc, m0, ni,
|
|
|
|
params->ibp_flags & IEEE80211_BPF_RTS ?
|
|
|
|
IEEE80211_PROT_RTSCTS : IEEE80211_PROT_CTSONLY,
|
|
|
|
rate);
|
|
|
|
if (error) {
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
flags |= RT2560_TX_LONG_RETRY | RT2560_TX_IFS_SIFS;
|
|
|
|
}
|
|
|
|
|
2006-07-26 03:30:50 +00:00
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->prioq.data_dmat, data->map, m0,
|
|
|
|
segs, &nsegs, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not map mbuf (error %d)\n",
|
|
|
|
error);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
if (ieee80211_radiotap_active_vap(vap)) {
|
2006-07-26 03:30:50 +00:00
|
|
|
struct rt2560_tx_radiotap_header *tap = &sc->sc_txtap;
|
|
|
|
|
|
|
|
tap->wt_flags = 0;
|
|
|
|
tap->wt_rate = rate;
|
|
|
|
tap->wt_antenna = sc->tx_ant;
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_tx(ni->ni_vap, m0);
|
2006-07-26 03:30:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data->m = m0;
|
|
|
|
data->ni = ni;
|
|
|
|
|
|
|
|
/* XXX need to setup descriptor ourself */
|
|
|
|
rt2560_setup_tx_desc(sc, desc, flags, m0->m_pkthdr.len,
|
|
|
|
rate, (params->ibp_flags & IEEE80211_BPF_CRYPTO) != 0,
|
|
|
|
segs->ds_addr);
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->prioq.data_dmat, data->map, BUS_DMASYNC_PREWRITE);
|
|
|
|
bus_dmamap_sync(sc->prioq.desc_dmat, sc->prioq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 10, "sending raw frame len=%u idx=%u rate=%u\n",
|
|
|
|
m0->m_pkthdr.len, sc->prioq.cur, rate);
|
2006-07-26 03:30:50 +00:00
|
|
|
|
|
|
|
/* kick prio */
|
|
|
|
sc->prioq.queued++;
|
|
|
|
sc->prioq.cur = (sc->prioq.cur + 1) % RT2560_PRIO_RING_COUNT;
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR0, RT2560_KICK_PRIO);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0,
|
|
|
|
struct ieee80211_node *ni)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ieee80211com *ic = ni->ni_ic;
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_desc *desc;
|
|
|
|
struct rt2560_tx_data *data;
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_frame *wh;
|
2008-04-20 20:35:46 +00:00
|
|
|
const struct ieee80211_txparam *tp;
|
2005-04-18 18:47:38 +00:00
|
|
|
struct ieee80211_key *k;
|
|
|
|
struct mbuf *mnew;
|
2006-03-05 20:36:56 +00:00
|
|
|
bus_dma_segment_t segs[RT2560_MAX_SCATTER];
|
2005-04-18 18:47:38 +00:00
|
|
|
uint16_t dur;
|
2008-04-20 20:35:46 +00:00
|
|
|
uint32_t flags;
|
2005-04-18 18:47:38 +00:00
|
|
|
int nsegs, rate, error;
|
|
|
|
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
|
|
|
|
if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
|
|
|
|
rate = tp->mcastrate;
|
|
|
|
} else if (m0->m_flags & M_EAPOL) {
|
|
|
|
rate = tp->mgmtrate;
|
|
|
|
} else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
|
|
|
|
rate = tp->ucastrate;
|
2005-04-18 18:47:38 +00:00
|
|
|
} else {
|
2010-04-07 15:29:13 +00:00
|
|
|
(void) ieee80211_ratectl_rate(ni, NULL, 0);
|
2008-04-20 20:35:46 +00:00
|
|
|
rate = ni->ni_txrate;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2014-01-08 08:06:56 +00:00
|
|
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
2008-04-20 20:35:46 +00:00
|
|
|
k = ieee80211_crypto_encap(ni, m0);
|
2005-07-07 02:55:04 +00:00
|
|
|
if (k == NULL) {
|
|
|
|
m_freem(m0);
|
2005-04-18 18:47:38 +00:00
|
|
|
return ENOBUFS;
|
2005-07-07 02:55:04 +00:00
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* packet header may have moved, reset our local pointer */
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
flags = 0;
|
|
|
|
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
|
|
|
|
int prot = IEEE80211_PROT_NONE;
|
|
|
|
if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold)
|
|
|
|
prot = IEEE80211_PROT_RTSCTS;
|
|
|
|
else if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
|
2009-03-29 21:17:08 +00:00
|
|
|
ieee80211_rate2phytype(ic->ic_rt, rate) == IEEE80211_T_OFDM)
|
2008-04-20 20:35:46 +00:00
|
|
|
prot = ic->ic_protmode;
|
|
|
|
if (prot != IEEE80211_PROT_NONE) {
|
|
|
|
error = rt2560_sendprot(sc, m0, ni, prot, rate);
|
|
|
|
if (error) {
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
flags |= RT2560_TX_LONG_RETRY | RT2560_TX_IFS_SIFS;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data = &sc->txq.data[sc->txq.cur_encrypt];
|
|
|
|
desc = &sc->txq.desc[sc->txq.cur_encrypt];
|
|
|
|
|
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->txq.data_dmat, data->map, m0,
|
|
|
|
segs, &nsegs, 0);
|
2005-06-29 17:54:01 +00:00
|
|
|
if (error != 0 && error != EFBIG) {
|
2005-04-18 18:47:38 +00:00
|
|
|
device_printf(sc->sc_dev, "could not map mbuf (error %d)\n",
|
|
|
|
error);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
2005-06-29 17:54:01 +00:00
|
|
|
if (error != 0) {
|
2012-12-04 09:32:43 +00:00
|
|
|
mnew = m_defrag(m0, M_NOWAIT);
|
2005-06-29 17:54:01 +00:00
|
|
|
if (mnew == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not defragment mbuf\n");
|
|
|
|
m_freem(m0);
|
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
m0 = mnew;
|
|
|
|
|
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->txq.data_dmat, data->map,
|
|
|
|
m0, segs, &nsegs, 0);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not map mbuf (error %d)\n", error);
|
|
|
|
m_freem(m0);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* packet header may have moved, reset our local pointer */
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
if (ieee80211_radiotap_active_vap(vap)) {
|
2006-03-05 20:36:56 +00:00
|
|
|
struct rt2560_tx_radiotap_header *tap = &sc->sc_txtap;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
tap->wt_flags = 0;
|
|
|
|
tap->wt_rate = rate;
|
|
|
|
tap->wt_antenna = sc->tx_ant;
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
ieee80211_radiotap_tx(vap, m0);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data->m = m0;
|
|
|
|
data->ni = ni;
|
|
|
|
|
|
|
|
/* remember link conditions for rate adaptation algorithm */
|
2008-04-20 20:35:46 +00:00
|
|
|
if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) {
|
|
|
|
data->rix = ni->ni_txrate;
|
|
|
|
/* XXX probably need last rssi value and not avg */
|
|
|
|
data->rssi = ic->ic_node_getrssi(ni);
|
2005-04-18 18:47:38 +00:00
|
|
|
} else
|
2008-04-20 20:35:46 +00:00
|
|
|
data->rix = IEEE80211_FIXED_RATE_NONE;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
|
2006-03-05 20:36:56 +00:00
|
|
|
flags |= RT2560_TX_ACK;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2009-03-29 21:17:08 +00:00
|
|
|
dur = ieee80211_ack_duration(ic->ic_rt,
|
2008-04-20 20:35:46 +00:00
|
|
|
rate, ic->ic_flags & IEEE80211_F_SHPREAMBLE);
|
2005-04-18 18:47:38 +00:00
|
|
|
*(uint16_t *)wh->i_dur = htole16(dur);
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_setup_tx_desc(sc, desc, flags, m0->m_pkthdr.len, rate, 1,
|
2005-04-18 18:47:38 +00:00
|
|
|
segs->ds_addr);
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->txq.data_dmat, data->map, BUS_DMASYNC_PREWRITE);
|
|
|
|
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 10, "sending data frame len=%u idx=%u rate=%u\n",
|
|
|
|
m0->m_pkthdr.len, sc->txq.cur_encrypt, rate);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* kick encrypt */
|
|
|
|
sc->txq.queued++;
|
2006-03-05 20:36:56 +00:00
|
|
|
sc->txq.cur_encrypt = (sc->txq.cur_encrypt + 1) % RT2560_TX_RING_COUNT;
|
|
|
|
RAL_WRITE(sc, RT2560_SECCSR1, RT2560_KICK_ENCRYPT);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
static int
|
|
|
|
rt2560_transmit(struct ieee80211com *ic, struct mbuf *m)
|
|
|
|
{
|
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
RAL_LOCK(sc);
|
|
|
|
if ((sc->sc_flags & RT2560_F_RUNNING) == 0) {
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
error = mbufq_enqueue(&sc->sc_snd, m);
|
|
|
|
if (error) {
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
rt2560_start(sc);
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
rt2560_start(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2015-08-08 01:10:17 +00:00
|
|
|
struct ieee80211_node *ni;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct mbuf *m;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
RAL_LOCK_ASSERT(sc);
|
2006-03-21 21:15:43 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
while (sc->txq.queued < RT2560_TX_RING_COUNT - 1 &&
|
|
|
|
(m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
|
2008-04-20 20:35:46 +00:00
|
|
|
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
|
|
|
|
if (rt2560_tx_data(sc, m, ni) != 0) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if_inc_counter(ni->ni_vap->iv_ifp,
|
|
|
|
IFCOUNTER_OERRORS, 1);
|
2008-04-20 20:35:46 +00:00
|
|
|
ieee80211_free_node(ni);
|
|
|
|
break;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
sc->sc_tx_timer = 5;
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
static void
|
2006-12-19 17:37:41 +00:00
|
|
|
rt2560_watchdog(void *arg)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2007-03-11 22:43:35 +00:00
|
|
|
struct rt2560_softc *sc = arg;
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
RAL_LOCK_ASSERT(sc);
|
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
KASSERT(sc->sc_flags & RT2560_F_RUNNING, ("not running"));
|
2008-04-20 20:35:46 +00:00
|
|
|
|
|
|
|
if (sc->sc_invalid) /* card ejected */
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
rt2560_encryption_intr(sc);
|
|
|
|
rt2560_tx_intr(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
device_printf(sc->sc_dev, "device timeout\n");
|
2008-04-20 20:35:46 +00:00
|
|
|
rt2560_init_locked(sc);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
counter_u64_add(sc->sc_ic.ic_oerrors, 1);
|
2008-04-20 20:35:46 +00:00
|
|
|
/* NB: callout is reset in rt2560_init() */
|
|
|
|
return;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
static void
|
|
|
|
rt2560_parent(struct ieee80211com *ic)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
|
|
|
int startall = 0;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
RAL_LOCK(sc);
|
|
|
|
if (ic->ic_nrunning > 0) {
|
|
|
|
if ((sc->sc_flags & RT2560_F_RUNNING) == 0) {
|
|
|
|
rt2560_init_locked(sc);
|
|
|
|
startall = 1;
|
|
|
|
} else
|
|
|
|
rt2560_update_promisc(ic);
|
|
|
|
} else if (sc->sc_flags & RT2560_F_RUNNING)
|
|
|
|
rt2560_stop_locked(sc);
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
if (startall)
|
|
|
|
ieee80211_start_all(ic);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_write(struct rt2560_softc *sc, uint8_t reg, uint8_t val)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
if (!(RAL_READ(sc, RT2560_BBPCSR) & RT2560_BBP_BUSY))
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
DELAY(1);
|
|
|
|
}
|
|
|
|
if (ntries == 100) {
|
|
|
|
device_printf(sc->sc_dev, "could not write to BBP\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RT2560_BBP_WRITE | RT2560_BBP_BUSY | reg << 8 | val;
|
|
|
|
RAL_WRITE(sc, RT2560_BBPCSR, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "BBP R%u <- 0x%02x\n", reg, val);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_read(struct rt2560_softc *sc, uint8_t reg)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
int ntries;
|
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
|
|
|
if (!(RAL_READ(sc, RT2560_BBPCSR) & RT2560_BBP_BUSY))
|
|
|
|
break;
|
|
|
|
DELAY(1);
|
|
|
|
}
|
|
|
|
if (ntries == 100) {
|
|
|
|
device_printf(sc->sc_dev, "could not read from BBP\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
val = RT2560_BBP_BUSY | reg << 8;
|
|
|
|
RAL_WRITE(sc, RT2560_BBPCSR, val);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
val = RAL_READ(sc, RT2560_BBPCSR);
|
|
|
|
if (!(val & RT2560_BBP_BUSY))
|
2005-04-18 18:47:38 +00:00
|
|
|
return val & 0xff;
|
|
|
|
DELAY(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
device_printf(sc->sc_dev, "could not read from BBP\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rf_write(struct rt2560_softc *sc, uint8_t reg, uint32_t val)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
if (!(RAL_READ(sc, RT2560_RFCSR) & RT2560_RF_BUSY))
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
DELAY(1);
|
|
|
|
}
|
|
|
|
if (ntries == 100) {
|
|
|
|
device_printf(sc->sc_dev, "could not write to RF\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RT2560_RF_BUSY | RT2560_RF_20BIT | (val & 0xfffff) << 2 |
|
|
|
|
(reg & 0x3);
|
|
|
|
RAL_WRITE(sc, RT2560_RFCSR, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* remember last written value in sc */
|
|
|
|
sc->rf_regs[reg] = val;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 15, "RF R[%u] <- 0x%05x\n", reg & 0x3, val & 0xfffff);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_set_chan(struct rt2560_softc *sc, struct ieee80211_channel *c)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint8_t power, tmp;
|
|
|
|
u_int i, chan;
|
|
|
|
|
|
|
|
chan = ieee80211_chan2ieee(ic, c);
|
2008-04-20 20:35:46 +00:00
|
|
|
KASSERT(chan != 0 && chan != IEEE80211_CHAN_ANY, ("chan 0x%x", chan));
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
if (IEEE80211_IS_CHAN_2GHZ(c))
|
|
|
|
power = min(sc->txpow[chan - 1], 31);
|
|
|
|
else
|
|
|
|
power = 31;
|
|
|
|
|
2006-01-29 12:47:07 +00:00
|
|
|
/* adjust txpower using ifconfig settings */
|
|
|
|
power -= (100 - ic->ic_txpowlimit) / 8;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 2, "setting channel to %u, txpower to %u\n", chan, power);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
switch (sc->rf_rev) {
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_2522:
|
|
|
|
rt2560_rf_write(sc, RAL_RF1, 0x00814);
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2522_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_2523:
|
|
|
|
rt2560_rf_write(sc, RAL_RF1, 0x08804);
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2523_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x38044);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_2524:
|
|
|
|
rt2560_rf_write(sc, RAL_RF1, 0x0c808);
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2524_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_2525:
|
|
|
|
rt2560_rf_write(sc, RAL_RF1, 0x08808);
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2525_hi_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rf_write(sc, RAL_RF1, 0x08808);
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2525_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_2525E:
|
|
|
|
rt2560_rf_write(sc, RAL_RF1, 0x08808);
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2525e_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00286 : 0x00282);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_2526:
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2526_hi_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, (chan & 1) ? 0x00386 : 0x00381);
|
|
|
|
rt2560_rf_write(sc, RAL_RF1, 0x08804);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf2526_r2[chan - 1]);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, (chan & 1) ? 0x00386 : 0x00381);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* dual-band RF */
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_5222:
|
|
|
|
for (i = 0; rt2560_rf5222[i].chan != chan; i++);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rf_write(sc, RAL_RF1, rt2560_rf5222[i].r1);
|
|
|
|
rt2560_rf_write(sc, RAL_RF2, rt2560_rf5222[i].r2);
|
|
|
|
rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040);
|
|
|
|
rt2560_rf_write(sc, RAL_RF4, rt2560_rf5222[i].r4);
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
default:
|
|
|
|
printf("unknown ral rev=%d\n", sc->rf_rev);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
/* XXX */
|
|
|
|
if ((ic->ic_flags & IEEE80211_F_SCAN) == 0) {
|
2005-04-18 18:47:38 +00:00
|
|
|
/* set Japan filter bit for channel 14 */
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = rt2560_bbp_read(sc, 70);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp &= ~RT2560_JAPAN_FILTER;
|
2005-04-18 18:47:38 +00:00
|
|
|
if (chan == 14)
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp |= RT2560_JAPAN_FILTER;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_write(sc, 70, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* clear CRC errors */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_READ(sc, RT2560_CNT0);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
static void
|
|
|
|
rt2560_set_channel(struct ieee80211com *ic)
|
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
|
|
|
RAL_LOCK(sc);
|
|
|
|
rt2560_set_chan(sc, ic->ic_curchan);
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* Disable RF auto-tuning.
|
|
|
|
*/
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_disable_rf_tune(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (sc->rf_rev != RT2560_RF_2523) {
|
2005-04-18 18:47:38 +00:00
|
|
|
tmp = sc->rf_regs[RAL_RF1] & ~RAL_RF1_AUTOTUNE;
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rf_write(sc, RAL_RF1, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tmp = sc->rf_regs[RAL_RF3] & ~RAL_RF3_AUTOTUNE;
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_rf_write(sc, RAL_RF3, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTFN(sc, 2, "%s", "disabling RF autotune\n");
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Refer to IEEE Std 802.11-1999 pp. 123 for more information on TSF
|
|
|
|
* synchronization.
|
|
|
|
*/
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_enable_tsf_sync(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
2005-04-18 18:47:38 +00:00
|
|
|
uint16_t logcwmin, preload;
|
|
|
|
uint32_t tmp;
|
|
|
|
|
|
|
|
/* first, disable TSF synchronization */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR14, 0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
tmp = 16 * vap->iv_bss->ni_intval;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR12, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR13, 0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
logcwmin = 5;
|
2008-04-20 20:35:46 +00:00
|
|
|
preload = (vap->iv_opmode == IEEE80211_M_STA) ? 384 : 1024;
|
2005-04-18 18:47:38 +00:00
|
|
|
tmp = logcwmin << 16 | preload;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_BCNOCSR, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* finally, enable TSF synchronization */
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RT2560_ENABLE_TSF | RT2560_ENABLE_TBCN;
|
2005-04-18 18:47:38 +00:00
|
|
|
if (ic->ic_opmode == IEEE80211_M_STA)
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp |= RT2560_ENABLE_TSF_SYNC(1);
|
2005-04-18 18:47:38 +00:00
|
|
|
else
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp |= RT2560_ENABLE_TSF_SYNC(2) |
|
|
|
|
RT2560_ENABLE_BEACON_GENERATOR;
|
|
|
|
RAL_WRITE(sc, RT2560_CSR14, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(sc, "%s", "enabling TSF synchronization\n");
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 20:00:40 +00:00
|
|
|
static void
|
|
|
|
rt2560_enable_tsf(struct rt2560_softc *sc)
|
|
|
|
{
|
|
|
|
RAL_WRITE(sc, RT2560_CSR14, 0);
|
|
|
|
RAL_WRITE(sc, RT2560_CSR14,
|
|
|
|
RT2560_ENABLE_TSF_SYNC(2) | RT2560_ENABLE_TSF);
|
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_update_plcp(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* no short preamble for 1Mbps */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_PLCP1MCSR, 0x00700400);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
if (!(ic->ic_flags & IEEE80211_F_SHPREAMBLE)) {
|
|
|
|
/* values taken from the reference driver */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_PLCP2MCSR, 0x00380401);
|
|
|
|
RAL_WRITE(sc, RT2560_PLCP5p5MCSR, 0x00150402);
|
|
|
|
RAL_WRITE(sc, RT2560_PLCP11MCSR, 0x000b8403);
|
2005-04-18 18:47:38 +00:00
|
|
|
} else {
|
|
|
|
/* same values as above or'ed 0x8 */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_PLCP2MCSR, 0x00380409);
|
|
|
|
RAL_WRITE(sc, RT2560_PLCP5p5MCSR, 0x0015040a);
|
|
|
|
RAL_WRITE(sc, RT2560_PLCP11MCSR, 0x000b840b);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(sc, "updating PLCP for %s preamble\n",
|
|
|
|
(ic->ic_flags & IEEE80211_F_SHPREAMBLE) ? "short" : "long");
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function can be called by ieee80211_set_shortslottime(). Refer to
|
|
|
|
* IEEE Std 802.11-1999 pp. 85 to know how these values are computed.
|
|
|
|
*/
|
|
|
|
static void
|
2015-05-25 19:53:29 +00:00
|
|
|
rt2560_update_slot(struct ieee80211com *ic)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2015-05-25 19:53:29 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint8_t slottime;
|
2005-08-21 14:16:20 +00:00
|
|
|
uint16_t tx_sifs, tx_pifs, tx_difs, eifs;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint32_t tmp;
|
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
#ifndef FORCE_SLOTTIME
|
2015-12-13 20:48:24 +00:00
|
|
|
slottime = IEEE80211_GET_SLOTTIME(ic);
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* Setting slot time according to "short slot time" capability
|
|
|
|
* in beacon/probe_resp seems to cause problem to acknowledge
|
|
|
|
* certain AP's data frames transimitted at CCK/DS rates: the
|
|
|
|
* problematic AP keeps retransmitting data frames, probably
|
|
|
|
* because MAC level acks are not received by hardware.
|
|
|
|
* So we cheat a little bit here by claiming we are capable of
|
|
|
|
* "short slot time" but setting hardware slot time to the normal
|
|
|
|
* slot time. ral(4) does not seem to have trouble to receive
|
|
|
|
* frames transmitted using short slot time even if hardware
|
|
|
|
* slot time is set to normal slot time. If we didn't use this
|
|
|
|
* trick, we would have to claim that short slot time is not
|
|
|
|
* supported; this would give relative poor RX performance
|
|
|
|
* (-1Mb~-2Mb lower) and the _whole_ BSS would stop using short
|
|
|
|
* slot time.
|
|
|
|
*/
|
2015-12-13 20:48:24 +00:00
|
|
|
slottime = IEEE80211_DUR_SLOT;
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
#endif
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* update the MAC slot boundaries */
|
2006-03-05 20:36:56 +00:00
|
|
|
tx_sifs = RAL_SIFS - RT2560_TXRX_TURNAROUND;
|
2005-08-21 14:16:20 +00:00
|
|
|
tx_pifs = tx_sifs + slottime;
|
2015-12-13 20:48:24 +00:00
|
|
|
tx_difs = IEEE80211_DUR_DIFS(tx_sifs, slottime);
|
2005-08-21 14:16:20 +00:00
|
|
|
eifs = (ic->ic_curmode == IEEE80211_MODE_11B) ? 364 : 60;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RAL_READ(sc, RT2560_CSR11);
|
2005-04-18 18:47:38 +00:00
|
|
|
tmp = (tmp & ~0x1f00) | slottime << 8;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR11, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2005-08-21 14:16:20 +00:00
|
|
|
tmp = tx_pifs << 16 | tx_sifs;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR18, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2005-08-21 14:16:20 +00:00
|
|
|
tmp = eifs << 16 | tx_difs;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR19, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(sc, "setting slottime to %uus\n", slottime);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2006-01-29 12:35:26 +00:00
|
|
|
static void
|
2011-04-09 14:45:50 +00:00
|
|
|
rt2560_set_basicrates(struct rt2560_softc *sc,
|
|
|
|
const struct ieee80211_rateset *rs)
|
2006-01-29 12:35:26 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2011-04-09 14:45:50 +00:00
|
|
|
uint32_t mask = 0;
|
|
|
|
uint8_t rate;
|
|
|
|
int i;
|
2006-01-29 12:35:26 +00:00
|
|
|
|
2011-04-09 14:45:50 +00:00
|
|
|
for (i = 0; i < rs->rs_nrates; i++) {
|
|
|
|
rate = rs->rs_rates[i];
|
|
|
|
|
|
|
|
if (!(rate & IEEE80211_RATE_BASIC))
|
|
|
|
continue;
|
|
|
|
|
2015-09-22 02:44:59 +00:00
|
|
|
mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt,
|
|
|
|
IEEE80211_RV(rate));
|
2006-01-29 12:35:26 +00:00
|
|
|
}
|
2011-04-09 14:45:50 +00:00
|
|
|
|
|
|
|
RAL_WRITE(sc, RT2560_ARSP_PLCP_1, mask);
|
|
|
|
|
|
|
|
DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask);
|
2006-01-29 12:35:26 +00:00
|
|
|
}
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_update_led(struct rt2560_softc *sc, int led1, int led2)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
|
|
|
/* set ON period to 70ms and OFF period to 30ms */
|
|
|
|
tmp = led1 << 16 | led2 << 17 | 70 << 8 | 30;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_LEDCSR, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
rt2560_set_bssid(struct rt2560_softc *sc, const uint8_t *bssid)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
|
|
|
tmp = bssid[0] | bssid[1] << 8 | bssid[2] << 16 | bssid[3] << 24;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR5, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
tmp = bssid[4] | bssid[5] << 8;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR6, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(sc, "setting BSSID to %6D\n", bssid, ":");
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
rt2560_set_macaddr(struct rt2560_softc *sc, const uint8_t *addr)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
|
|
|
tmp = addr[0] | addr[1] << 8 | addr[2] << 16 | addr[3] << 24;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR3, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
tmp = addr[4] | addr[5] << 8;
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR4, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(sc, "setting MAC address to %6D\n", addr, ":");
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_get_macaddr(struct rt2560_softc *sc, uint8_t *addr)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RAL_READ(sc, RT2560_CSR3);
|
2005-04-18 18:47:38 +00:00
|
|
|
addr[0] = tmp & 0xff;
|
|
|
|
addr[1] = (tmp >> 8) & 0xff;
|
|
|
|
addr[2] = (tmp >> 16) & 0xff;
|
|
|
|
addr[3] = (tmp >> 24);
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RAL_READ(sc, RT2560_CSR4);
|
2005-04-18 18:47:38 +00:00
|
|
|
addr[4] = tmp & 0xff;
|
|
|
|
addr[5] = (tmp >> 8) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-05-25 19:53:29 +00:00
|
|
|
rt2560_update_promisc(struct ieee80211com *ic)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
2015-05-25 19:53:29 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
2005-04-18 18:47:38 +00:00
|
|
|
uint32_t tmp;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RAL_READ(sc, RT2560_RXCSR0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp &= ~RT2560_DROP_NOT_TO_ME;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (ic->ic_promisc == 0)
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp |= RT2560_DROP_NOT_TO_ME;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_RXCSR0, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2015-05-25 19:53:29 +00:00
|
|
|
DPRINTF(sc, "%s promiscuous mode\n",
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
(ic->ic_promisc > 0) ? "entering" : "leaving");
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_get_rf(int rev)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
switch (rev) {
|
2006-03-05 20:36:56 +00:00
|
|
|
case RT2560_RF_2522: return "RT2522";
|
|
|
|
case RT2560_RF_2523: return "RT2523";
|
|
|
|
case RT2560_RF_2524: return "RT2524";
|
|
|
|
case RT2560_RF_2525: return "RT2525";
|
|
|
|
case RT2560_RF_2525E: return "RT2525e";
|
|
|
|
case RT2560_RF_2526: return "RT2526";
|
|
|
|
case RT2560_RF_5222: return "RT5222";
|
2005-04-18 18:47:38 +00:00
|
|
|
default: return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
rt2560_read_config(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint16_t val;
|
|
|
|
int i;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
val = rt2560_eeprom_read(sc, RT2560_EEPROM_CONFIG0);
|
2005-04-18 18:47:38 +00:00
|
|
|
sc->rf_rev = (val >> 11) & 0x7;
|
|
|
|
sc->hw_radio = (val >> 10) & 0x1;
|
|
|
|
sc->led_mode = (val >> 6) & 0x7;
|
|
|
|
sc->rx_ant = (val >> 4) & 0x3;
|
|
|
|
sc->tx_ant = (val >> 2) & 0x3;
|
|
|
|
sc->nb_ant = val & 0x3;
|
|
|
|
|
|
|
|
/* read default values for BBP registers */
|
|
|
|
for (i = 0; i < 16; i++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
val = rt2560_eeprom_read(sc, RT2560_EEPROM_BBP_BASE + i);
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
if (val == 0 || val == 0xffff)
|
|
|
|
continue;
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
sc->bbp_prom[i].reg = val >> 8;
|
|
|
|
sc->bbp_prom[i].val = val & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read Tx power for all b/g channels */
|
|
|
|
for (i = 0; i < 14 / 2; i++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
val = rt2560_eeprom_read(sc, RT2560_EEPROM_TXPOWER + i);
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
sc->txpow[i * 2] = val & 0xff;
|
|
|
|
sc->txpow[i * 2 + 1] = val >> 8;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 14; ++i) {
|
|
|
|
if (sc->txpow[i] > 31)
|
|
|
|
sc->txpow[i] = 24;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
|
|
|
val = rt2560_eeprom_read(sc, RT2560_EEPROM_CALIBRATE);
|
|
|
|
if ((val & 0xff) == 0xff)
|
|
|
|
sc->rssi_corr = RT2560_DEFAULT_RSSI_CORR;
|
|
|
|
else
|
|
|
|
sc->rssi_corr = val & 0xff;
|
2008-04-20 20:35:46 +00:00
|
|
|
DPRINTF(sc, "rssi correction %d, calibrate 0x%02x\n",
|
|
|
|
sc->rssi_corr, val);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
rt2560_scan_start(struct ieee80211com *ic)
|
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
|
|
|
/* abort TSF synchronization */
|
|
|
|
RAL_WRITE(sc, RT2560_CSR14, 0);
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
rt2560_set_bssid(sc, ieee80211broadcastaddr);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rt2560_scan_end(struct ieee80211com *ic)
|
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = ic->ic_scan->ss_vap;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
|
|
|
rt2560_enable_tsf_sync(sc);
|
|
|
|
/* XXX keep local copy */
|
2008-04-20 20:35:46 +00:00
|
|
|
rt2560_set_bssid(sc, vap->iv_bss->ni_bssid);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_init(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
int i, ntries;
|
|
|
|
|
|
|
|
/* wait for BBP to be ready */
|
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
if (rt2560_bbp_read(sc, RT2560_BBP_VERSION) != 0)
|
2005-04-18 18:47:38 +00:00
|
|
|
break;
|
|
|
|
DELAY(1);
|
|
|
|
}
|
|
|
|
if (ntries == 100) {
|
|
|
|
device_printf(sc->sc_dev, "timeout waiting for BBP\n");
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize BBP registers to default values */
|
2015-09-22 02:44:59 +00:00
|
|
|
for (i = 0; i < nitems(rt2560_def_bbp); i++) {
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_write(sc, rt2560_def_bbp[i].reg,
|
|
|
|
rt2560_def_bbp[i].val);
|
|
|
|
}
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/* initialize BBP registers to values stored in EEPROM */
|
|
|
|
for (i = 0; i < 16; i++) {
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
if (sc->bbp_prom[i].reg == 0 && sc->bbp_prom[i].val == 0)
|
|
|
|
break;
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_write(sc, sc->bbp_prom[i].reg, sc->bbp_prom[i].val);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
rt2560_bbp_write(sc, 17, 0x48); /* XXX restore bbp17 */
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_set_txantenna(struct rt2560_softc *sc, int antenna)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
uint8_t tx;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
tx = rt2560_bbp_read(sc, RT2560_BBP_TX) & ~RT2560_BBP_ANTMASK;
|
2005-04-18 18:47:38 +00:00
|
|
|
if (antenna == 1)
|
2006-03-05 20:36:56 +00:00
|
|
|
tx |= RT2560_BBP_ANTA;
|
2005-04-18 18:47:38 +00:00
|
|
|
else if (antenna == 2)
|
2006-03-05 20:36:56 +00:00
|
|
|
tx |= RT2560_BBP_ANTB;
|
2005-04-18 18:47:38 +00:00
|
|
|
else
|
2006-03-05 20:36:56 +00:00
|
|
|
tx |= RT2560_BBP_DIVERSITY;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* need to force I/Q flip for RF 2525e, 2526 and 5222 */
|
2006-03-05 20:36:56 +00:00
|
|
|
if (sc->rf_rev == RT2560_RF_2525E || sc->rf_rev == RT2560_RF_2526 ||
|
|
|
|
sc->rf_rev == RT2560_RF_5222)
|
|
|
|
tx |= RT2560_BBP_FLIPIQ;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_write(sc, RT2560_BBP_TX, tx);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* update values for CCK and OFDM in BBPCSR1 */
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RAL_READ(sc, RT2560_BBPCSR1) & ~0x00070007;
|
2005-04-18 18:47:38 +00:00
|
|
|
tmp |= (tx & 0x7) << 16 | (tx & 0x7);
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_BBPCSR1, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_set_rxantenna(struct rt2560_softc *sc, int antenna)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
|
|
|
uint8_t rx;
|
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rx = rt2560_bbp_read(sc, RT2560_BBP_RX) & ~RT2560_BBP_ANTMASK;
|
2005-04-18 18:47:38 +00:00
|
|
|
if (antenna == 1)
|
2006-03-05 20:36:56 +00:00
|
|
|
rx |= RT2560_BBP_ANTA;
|
2005-04-18 18:47:38 +00:00
|
|
|
else if (antenna == 2)
|
2006-03-05 20:36:56 +00:00
|
|
|
rx |= RT2560_BBP_ANTB;
|
2005-04-18 18:47:38 +00:00
|
|
|
else
|
2006-03-05 20:36:56 +00:00
|
|
|
rx |= RT2560_BBP_DIVERSITY;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* need to force no I/Q flip for RF 2525e and 2526 */
|
2006-03-05 20:36:56 +00:00
|
|
|
if (sc->rf_rev == RT2560_RF_2525E || sc->rf_rev == RT2560_RF_2526)
|
|
|
|
rx &= ~RT2560_BBP_FLIPIQ;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_bbp_write(sc, RT2560_BBP_RX, rx);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-20 20:35:46 +00:00
|
|
|
rt2560_init_locked(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
2005-04-18 18:47:38 +00:00
|
|
|
uint32_t tmp;
|
|
|
|
int i;
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
RAL_LOCK_ASSERT(sc);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
rt2560_stop_locked(sc);
|
2006-03-21 21:15:43 +00:00
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/* setup tx rings */
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RT2560_PRIO_RING_COUNT << 24 |
|
|
|
|
RT2560_ATIM_RING_COUNT << 16 |
|
|
|
|
RT2560_TX_RING_COUNT << 8 |
|
|
|
|
RT2560_TX_DESC_SIZE;
|
|
|
|
|
|
|
|
/* rings must be initialized in this exact order */
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR2, tmp);
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR3, sc->txq.physaddr);
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR5, sc->prioq.physaddr);
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR4, sc->atimq.physaddr);
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR6, sc->bcnq.physaddr);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* setup rx ring */
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RT2560_RX_RING_COUNT << 8 | RT2560_RX_DESC_SIZE;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_RXCSR1, tmp);
|
|
|
|
RAL_WRITE(sc, RT2560_RXCSR2, sc->rxq.physaddr);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* initialize MAC registers to default values */
|
2015-09-22 02:44:59 +00:00
|
|
|
for (i = 0; i < nitems(rt2560_def_mac); i++)
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, rt2560_def_mac[i].reg, rt2560_def_mac[i].val);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
rt2560_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2005-08-21 14:16:20 +00:00
|
|
|
/* set basic rate set (will be updated later) */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x153);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2015-05-25 19:53:29 +00:00
|
|
|
rt2560_update_slot(ic);
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_update_plcp(sc);
|
|
|
|
rt2560_update_led(sc, 0, 0);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC);
|
|
|
|
RAL_WRITE(sc, RT2560_CSR1, RT2560_HOST_READY);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2006-03-05 20:36:56 +00:00
|
|
|
if (rt2560_bbp_init(sc) != 0) {
|
2010-09-29 11:52:44 +00:00
|
|
|
rt2560_stop_locked(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
rt2560_set_txantenna(sc, sc->tx_ant);
|
|
|
|
rt2560_set_rxantenna(sc, sc->rx_ant);
|
|
|
|
|
2005-04-18 18:47:38 +00:00
|
|
|
/* set default BSS channel */
|
2006-03-05 20:36:56 +00:00
|
|
|
rt2560_set_chan(sc, ic->ic_curchan);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* kick Rx */
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp = RT2560_DROP_PHY_ERROR | RT2560_DROP_CRC_ERROR;
|
2005-04-18 18:47:38 +00:00
|
|
|
if (ic->ic_opmode != IEEE80211_M_MONITOR) {
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp |= RT2560_DROP_CTL | RT2560_DROP_VERSION_ERROR;
|
Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.
Authentication and encryption are not implemented.
There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).
A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.
Drivers that support mesh networks right now are: ath, ral and mwl.
More information at: http://wiki.freebsd.org/WifiMesh
Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.
Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.
Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s
2009-07-11 15:02:45 +00:00
|
|
|
if (ic->ic_opmode != IEEE80211_M_HOSTAP &&
|
|
|
|
ic->ic_opmode != IEEE80211_M_MBSS)
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp |= RT2560_DROP_TODS;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (ic->ic_promisc == 0)
|
2006-03-05 20:36:56 +00:00
|
|
|
tmp |= RT2560_DROP_NOT_TO_ME;
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_RXCSR0, tmp);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* clear old FCS and Rx FIFO errors */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_READ(sc, RT2560_CNT0);
|
|
|
|
RAL_READ(sc, RT2560_CNT4);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* clear any pending interrupts */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR7, 0xffffffff);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
|
|
|
/* enable interrupts */
|
2006-03-05 20:36:56 +00:00
|
|
|
RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
sc->sc_flags |= RT2560_F_RUNNING;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static void
|
|
|
|
rt2560_init(void *priv)
|
|
|
|
{
|
|
|
|
struct rt2560_softc *sc = priv;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2006-03-21 21:15:43 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
RAL_LOCK(sc);
|
|
|
|
rt2560_init_locked(sc);
|
2006-03-21 21:15:43 +00:00
|
|
|
RAL_UNLOCK(sc);
|
2008-04-20 20:35:46 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (sc->sc_flags & RT2560_F_RUNNING)
|
2008-05-10 20:25:59 +00:00
|
|
|
ieee80211_start_all(ic); /* start all vap's */
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
static void
|
|
|
|
rt2560_stop_locked(struct rt2560_softc *sc)
|
2005-04-18 18:47:38 +00:00
|
|
|
{
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
volatile int *flags = &sc->sc_flags;
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
RAL_LOCK_ASSERT(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
while (*flags & RT2560_F_INPUT_RUNNING)
|
|
|
|
msleep(sc, &sc->sc_mtx, 0, "ralrunning", hz/10);
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
|
|
|
|
callout_stop(&sc->watchdog_ch);
|
2008-04-20 20:35:46 +00:00
|
|
|
sc->sc_tx_timer = 0;
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (sc->sc_flags & RT2560_F_RUNNING) {
|
|
|
|
sc->sc_flags &= ~RT2560_F_RUNNING;
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
|
|
|
|
/* abort Tx */
|
|
|
|
RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX);
|
|
|
|
|
|
|
|
/* disable Rx */
|
|
|
|
RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX);
|
|
|
|
|
|
|
|
/* reset ASIC (imply reset BBP) */
|
|
|
|
RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC);
|
|
|
|
RAL_WRITE(sc, RT2560_CSR1, 0);
|
|
|
|
|
|
|
|
/* disable interrupts */
|
|
|
|
RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
|
|
|
|
|
|
|
|
/* reset Tx and Rx rings */
|
|
|
|
rt2560_reset_tx_ring(sc, &sc->txq);
|
|
|
|
rt2560_reset_tx_ring(sc, &sc->atimq);
|
|
|
|
rt2560_reset_tx_ring(sc, &sc->prioq);
|
|
|
|
rt2560_reset_tx_ring(sc, &sc->bcnq);
|
|
|
|
rt2560_reset_rx_ring(sc, &sc->rxq);
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
}
|
Various bug fixes for 2560 parts of ral(4):
- Rename rt2560_read_eeprom to rt2560_read_config, we already have
rt2560_eeprom_read
- If hardware gives us wrong encryption done index, shout out loudly and
terminate the processing loop
- Process encryption done if RX done bit is set in interrupt status register
(according to Ralink Linux driver)
- Turn VALID/BUSY bits in TX descriptor only after TX descriptor is fully setup
- Fix BBP read: RT2560_BBPCSR can't be written until its RT2560_BBP_BUSY bit is
off (according to Ralink Linux driver)
- Skip invalid (0 of 0xffff) BBP register/value entries stored in EEPROM
- Fix channel TX power location in EEPROM, if channel TX power is above 31 set
it to 24 (TX power only has 5bits in RF register, "24" is according to Ralink
Linux driver)
- Configure BBP according to the BBP register/value stored in EEPROM, restore
BBP17 (RX sensitivity tuning) to default value after this.
- Set TX/RX antenna after BBP is initialized; these two operation will try to
set BBP registers
- Reconfigure ACK TX time registers according to 802.11g standard (TX @36Mb,
other side's ACK should be sent @24Mb).
- 2560 parts have two TX ring: one for management/control packets, one for data
packets. Add private OACTIVE flag for each of them. Turn on IFF_DRV_OACTIVE
if one of private OACTIVE is on; turn off IFF_DRV_OACTIVE iff all of them are
off.
- Rework watchdog to mimic old if_watchdog action. Process TX done/encryption
done in watchdog function (according to Ralink Linux driver)
Obtained from: DragonFly
Approved by: sam (mentor)
Tested by: sam
Related to PR: kern/117655
# Forcing long slot time setting is not included in this commit, comment and
# related code is in place, so if problem pops up, quick tests could be done.
2008-02-03 11:47:38 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
void
|
|
|
|
rt2560_stop(void *arg)
|
|
|
|
{
|
|
|
|
struct rt2560_softc *sc = arg;
|
|
|
|
|
|
|
|
RAL_LOCK(sc);
|
|
|
|
rt2560_stop_locked(sc);
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
RAL_UNLOCK(sc);
|
2005-04-18 18:47:38 +00:00
|
|
|
}
|
2006-07-26 03:30:50 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
|
|
|
const struct ieee80211_bpf_params *params)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = ni->ni_ic;
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
struct rt2560_softc *sc = ic->ic_softc;
|
2006-07-26 03:30:50 +00:00
|
|
|
|
|
|
|
RAL_LOCK(sc);
|
|
|
|
|
|
|
|
/* prevent management frames from being sent if we're not ready */
|
Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.
Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.
Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:
- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.
Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.
Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.
Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
2015-08-27 08:56:39 +00:00
|
|
|
if (!(sc->sc_flags & RT2560_F_RUNNING)) {
|
2006-07-26 03:30:50 +00:00
|
|
|
RAL_UNLOCK(sc);
|
2007-04-19 13:09:57 +00:00
|
|
|
m_freem(m);
|
2006-07-26 03:30:50 +00:00
|
|
|
return ENETDOWN;
|
|
|
|
}
|
|
|
|
if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) {
|
|
|
|
RAL_UNLOCK(sc);
|
2007-04-19 13:09:57 +00:00
|
|
|
m_freem(m);
|
2006-07-26 03:30:50 +00:00
|
|
|
return ENOBUFS; /* XXX */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params == NULL) {
|
|
|
|
/*
|
|
|
|
* Legacy path; interpret frame contents to decide
|
|
|
|
* precisely how to send the frame.
|
|
|
|
*/
|
|
|
|
if (rt2560_tx_mgt(sc, m, ni) != 0)
|
|
|
|
goto bad;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Caller supplied explicit parameters to use in
|
|
|
|
* sending the frame.
|
|
|
|
*/
|
|
|
|
if (rt2560_tx_raw(sc, m, ni, params))
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
sc->sc_tx_timer = 5;
|
|
|
|
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
bad:
|
|
|
|
RAL_UNLOCK(sc);
|
|
|
|
return EIO; /* XXX */
|
|
|
|
}
|