2013-07-30 02:07:57 +00:00
|
|
|
/* $OpenBSD: if_rsu.c,v 1.17 2013/04/15 09:23:01 mglocker Exp $ */
|
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2010 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$");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Driver for Realtek RTL8188SU/RTL8191SU/RTL8192SU.
|
|
|
|
*
|
|
|
|
* TODO:
|
2016-12-06 00:13:49 +00:00
|
|
|
* o tx a-mpdu
|
2016-12-10 18:47:13 +00:00
|
|
|
* o hostap / ibss / mesh
|
2015-09-21 02:32:11 +00:00
|
|
|
* o power-save operation
|
2013-07-30 02:07:57 +00:00
|
|
|
*/
|
2015-09-12 23:10:34 +00:00
|
|
|
|
2015-09-28 01:16:44 +00:00
|
|
|
#include "opt_wlan.h"
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/endian.h>
|
|
|
|
#include <sys/sockio.h>
|
2016-02-01 17:41:21 +00:00
|
|
|
#include <sys/malloc.h>
|
2013-07-30 02:07:57 +00:00
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <sys/firmware.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2013-07-30 02:07:57 +00:00
|
|
|
#include <net/if_arp.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
|
|
|
#include <net80211/ieee80211_regdomain.h>
|
|
|
|
#include <net80211/ieee80211_radiotap.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usb.h>
|
|
|
|
#include <dev/usb/usbdi.h>
|
|
|
|
#include "usbdevs.h"
|
|
|
|
|
2017-11-02 00:17:52 +00:00
|
|
|
#include <dev/rtwn/if_rtwn_ridx.h> /* XXX */
|
2013-07-30 02:07:57 +00:00
|
|
|
#include <dev/usb/wlan/if_rsureg.h>
|
|
|
|
|
2017-11-02 00:17:52 +00:00
|
|
|
#define RSU_RATE_IS_CCK RTWN_RATE_IS_CCK
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
#ifdef USB_DEBUG
|
|
|
|
static int rsu_debug = 0;
|
|
|
|
SYSCTL_NODE(_hw_usb, OID_AUTO, rsu, CTLFLAG_RW, 0, "USB rsu");
|
2015-01-05 15:04:17 +00:00
|
|
|
SYSCTL_INT(_hw_usb_rsu, OID_AUTO, debug, CTLFLAG_RWTUN, &rsu_debug, 0,
|
2013-07-30 02:07:57 +00:00
|
|
|
"Debug level");
|
2015-09-12 23:10:34 +00:00
|
|
|
#define RSU_DPRINTF(_sc, _flg, ...) \
|
|
|
|
do \
|
|
|
|
if (((_flg) == (RSU_DEBUG_ANY)) || (rsu_debug & (_flg))) \
|
|
|
|
device_printf((_sc)->sc_dev, __VA_ARGS__); \
|
|
|
|
while (0)
|
|
|
|
#else
|
|
|
|
#define RSU_DPRINTF(_sc, _flg, ...)
|
2013-07-30 02:07:57 +00:00
|
|
|
#endif
|
|
|
|
|
2015-09-21 02:32:11 +00:00
|
|
|
static int rsu_enable_11n = 1;
|
2015-09-18 04:12:11 +00:00
|
|
|
TUNABLE_INT("hw.usb.rsu.enable_11n", &rsu_enable_11n);
|
|
|
|
|
2015-09-12 23:10:34 +00:00
|
|
|
#define RSU_DEBUG_ANY 0xffffffff
|
|
|
|
#define RSU_DEBUG_TX 0x00000001
|
|
|
|
#define RSU_DEBUG_RX 0x00000002
|
|
|
|
#define RSU_DEBUG_RESET 0x00000004
|
|
|
|
#define RSU_DEBUG_CALIB 0x00000008
|
|
|
|
#define RSU_DEBUG_STATE 0x00000010
|
|
|
|
#define RSU_DEBUG_SCAN 0x00000020
|
|
|
|
#define RSU_DEBUG_FWCMD 0x00000040
|
|
|
|
#define RSU_DEBUG_TXDONE 0x00000080
|
|
|
|
#define RSU_DEBUG_FW 0x00000100
|
|
|
|
#define RSU_DEBUG_FWDBG 0x00000200
|
2015-09-22 02:57:18 +00:00
|
|
|
#define RSU_DEBUG_AMPDU 0x00000400
|
2016-12-06 00:13:49 +00:00
|
|
|
#define RSU_DEBUG_KEY 0x00000800
|
2016-12-10 20:19:57 +00:00
|
|
|
#define RSU_DEBUG_USB 0x00001000
|
2015-09-12 23:10:34 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static const STRUCT_USB_HOST_ID rsu_devs[] = {
|
|
|
|
#define RSU_HT_NOT_SUPPORTED 0
|
|
|
|
#define RSU_HT_SUPPORTED 1
|
|
|
|
#define RSU_DEV_HT(v,p) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, \
|
|
|
|
RSU_HT_SUPPORTED) }
|
|
|
|
#define RSU_DEV(v,p) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, \
|
|
|
|
RSU_HT_NOT_SUPPORTED) }
|
|
|
|
RSU_DEV(ASUS, RTL8192SU),
|
|
|
|
RSU_DEV(AZUREWAVE, RTL8192SU_4),
|
|
|
|
RSU_DEV_HT(ACCTON, RTL8192SU),
|
|
|
|
RSU_DEV_HT(ASUS, USBN10),
|
|
|
|
RSU_DEV_HT(AZUREWAVE, RTL8192SU_1),
|
|
|
|
RSU_DEV_HT(AZUREWAVE, RTL8192SU_2),
|
|
|
|
RSU_DEV_HT(AZUREWAVE, RTL8192SU_3),
|
|
|
|
RSU_DEV_HT(AZUREWAVE, RTL8192SU_5),
|
|
|
|
RSU_DEV_HT(BELKIN, RTL8192SU_1),
|
|
|
|
RSU_DEV_HT(BELKIN, RTL8192SU_2),
|
|
|
|
RSU_DEV_HT(BELKIN, RTL8192SU_3),
|
|
|
|
RSU_DEV_HT(CONCEPTRONIC2, RTL8192SU_1),
|
|
|
|
RSU_DEV_HT(CONCEPTRONIC2, RTL8192SU_2),
|
|
|
|
RSU_DEV_HT(CONCEPTRONIC2, RTL8192SU_3),
|
|
|
|
RSU_DEV_HT(COREGA, RTL8192SU),
|
|
|
|
RSU_DEV_HT(DLINK2, DWA131A1),
|
|
|
|
RSU_DEV_HT(DLINK2, RTL8192SU_1),
|
|
|
|
RSU_DEV_HT(DLINK2, RTL8192SU_2),
|
|
|
|
RSU_DEV_HT(EDIMAX, RTL8192SU_1),
|
|
|
|
RSU_DEV_HT(EDIMAX, RTL8192SU_2),
|
2013-11-12 02:34:48 +00:00
|
|
|
RSU_DEV_HT(EDIMAX, EW7622UMN),
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_DEV_HT(GUILLEMOT, HWGUN54),
|
|
|
|
RSU_DEV_HT(GUILLEMOT, HWNUM300),
|
|
|
|
RSU_DEV_HT(HAWKING, RTL8192SU_1),
|
|
|
|
RSU_DEV_HT(HAWKING, RTL8192SU_2),
|
|
|
|
RSU_DEV_HT(PLANEX2, GWUSNANO),
|
|
|
|
RSU_DEV_HT(REALTEK, RTL8171),
|
|
|
|
RSU_DEV_HT(REALTEK, RTL8172),
|
|
|
|
RSU_DEV_HT(REALTEK, RTL8173),
|
|
|
|
RSU_DEV_HT(REALTEK, RTL8174),
|
|
|
|
RSU_DEV_HT(REALTEK, RTL8192SU),
|
|
|
|
RSU_DEV_HT(REALTEK, RTL8712),
|
|
|
|
RSU_DEV_HT(REALTEK, RTL8713),
|
|
|
|
RSU_DEV_HT(SENAO, RTL8192SU_1),
|
|
|
|
RSU_DEV_HT(SENAO, RTL8192SU_2),
|
|
|
|
RSU_DEV_HT(SITECOMEU, WL349V1),
|
|
|
|
RSU_DEV_HT(SITECOMEU, WL353),
|
|
|
|
RSU_DEV_HT(SWEEX2, LW154),
|
2014-11-19 05:38:45 +00:00
|
|
|
RSU_DEV_HT(TRENDNET, TEW646UBH),
|
2013-07-30 02:07:57 +00:00
|
|
|
#undef RSU_DEV_HT
|
|
|
|
#undef RSU_DEV
|
|
|
|
};
|
|
|
|
|
|
|
|
static device_probe_t rsu_match;
|
|
|
|
static device_attach_t rsu_attach;
|
|
|
|
static device_detach_t rsu_detach;
|
2014-06-04 09:18:13 +00:00
|
|
|
static usb_callback_t rsu_bulk_tx_callback_be_bk;
|
|
|
|
static usb_callback_t rsu_bulk_tx_callback_vi_vo;
|
2015-09-17 03:19:09 +00:00
|
|
|
static usb_callback_t rsu_bulk_tx_callback_h2c;
|
2013-07-30 02:07:57 +00:00
|
|
|
static usb_callback_t rsu_bulk_rx_callback;
|
|
|
|
static usb_error_t rsu_do_request(struct rsu_softc *,
|
|
|
|
struct usb_device_request *, void *);
|
|
|
|
static struct ieee80211vap *
|
|
|
|
rsu_vap_create(struct ieee80211com *, const char name[],
|
|
|
|
int, enum ieee80211_opmode, int, const uint8_t bssid[],
|
|
|
|
const uint8_t mac[]);
|
|
|
|
static void rsu_vap_delete(struct ieee80211vap *);
|
|
|
|
static void rsu_scan_start(struct ieee80211com *);
|
|
|
|
static void rsu_scan_end(struct ieee80211com *);
|
2016-05-26 16:39:11 +00:00
|
|
|
static void rsu_getradiocaps(struct ieee80211com *, int, int *,
|
|
|
|
struct ieee80211_channel[]);
|
2013-07-30 02:07:57 +00:00
|
|
|
static void rsu_set_channel(struct ieee80211com *);
|
2016-11-27 12:03:34 +00:00
|
|
|
static void rsu_scan_curchan(struct ieee80211_scan_state *, unsigned long);
|
|
|
|
static void rsu_scan_mindwell(struct ieee80211_scan_state *);
|
2016-12-10 18:47:13 +00:00
|
|
|
static void rsu_update_promisc(struct ieee80211com *);
|
2016-11-27 18:06:03 +00:00
|
|
|
static uint8_t rsu_get_multi_pos(const uint8_t[]);
|
|
|
|
static void rsu_set_multi(struct rsu_softc *);
|
2015-05-25 19:53:29 +00:00
|
|
|
static void rsu_update_mcast(struct ieee80211com *);
|
2013-07-30 02:07:57 +00:00
|
|
|
static int rsu_alloc_rx_list(struct rsu_softc *);
|
|
|
|
static void rsu_free_rx_list(struct rsu_softc *);
|
|
|
|
static int rsu_alloc_tx_list(struct rsu_softc *);
|
|
|
|
static void rsu_free_tx_list(struct rsu_softc *);
|
|
|
|
static void rsu_free_list(struct rsu_softc *, struct rsu_data [], int);
|
|
|
|
static struct rsu_data *_rsu_getbuf(struct rsu_softc *);
|
|
|
|
static struct rsu_data *rsu_getbuf(struct rsu_softc *);
|
2015-09-18 07:26:34 +00:00
|
|
|
static void rsu_freebuf(struct rsu_softc *, struct rsu_data *);
|
2013-07-30 02:07:57 +00:00
|
|
|
static int rsu_write_region_1(struct rsu_softc *, uint16_t, uint8_t *,
|
|
|
|
int);
|
|
|
|
static void rsu_write_1(struct rsu_softc *, uint16_t, uint8_t);
|
|
|
|
static void rsu_write_2(struct rsu_softc *, uint16_t, uint16_t);
|
|
|
|
static void rsu_write_4(struct rsu_softc *, uint16_t, uint32_t);
|
|
|
|
static int rsu_read_region_1(struct rsu_softc *, uint16_t, uint8_t *,
|
|
|
|
int);
|
|
|
|
static uint8_t rsu_read_1(struct rsu_softc *, uint16_t);
|
|
|
|
static uint16_t rsu_read_2(struct rsu_softc *, uint16_t);
|
|
|
|
static uint32_t rsu_read_4(struct rsu_softc *, uint16_t);
|
|
|
|
static int rsu_fw_iocmd(struct rsu_softc *, uint32_t);
|
|
|
|
static uint8_t rsu_efuse_read_1(struct rsu_softc *, uint16_t);
|
|
|
|
static int rsu_read_rom(struct rsu_softc *);
|
|
|
|
static int rsu_fw_cmd(struct rsu_softc *, uint8_t, void *, int);
|
|
|
|
static void rsu_calib_task(void *, int);
|
2015-09-21 02:30:22 +00:00
|
|
|
static void rsu_tx_task(void *, int);
|
2016-12-10 18:47:13 +00:00
|
|
|
static void rsu_set_led(struct rsu_softc *, int);
|
|
|
|
static int rsu_monitor_newstate(struct ieee80211vap *,
|
|
|
|
enum ieee80211_state, int);
|
2013-07-30 02:07:57 +00:00
|
|
|
static int rsu_newstate(struct ieee80211vap *, enum ieee80211_state, int);
|
2016-12-06 00:13:49 +00:00
|
|
|
static int rsu_key_alloc(struct ieee80211vap *, struct ieee80211_key *,
|
|
|
|
ieee80211_keyix *, ieee80211_keyix *);
|
|
|
|
static int rsu_process_key(struct ieee80211vap *,
|
|
|
|
const struct ieee80211_key *, int);
|
|
|
|
static int rsu_key_set(struct ieee80211vap *,
|
|
|
|
const struct ieee80211_key *);
|
|
|
|
static int rsu_key_delete(struct ieee80211vap *,
|
|
|
|
const struct ieee80211_key *);
|
|
|
|
static int rsu_cam_read(struct rsu_softc *, uint8_t, uint32_t *);
|
|
|
|
static void rsu_cam_write(struct rsu_softc *, uint8_t, uint32_t);
|
|
|
|
static int rsu_key_check(struct rsu_softc *, ieee80211_keyix, int);
|
|
|
|
static uint8_t rsu_crypto_mode(struct rsu_softc *, u_int, int);
|
|
|
|
static int rsu_set_key_group(struct rsu_softc *,
|
|
|
|
const struct ieee80211_key *);
|
|
|
|
static int rsu_set_key_pair(struct rsu_softc *,
|
|
|
|
const struct ieee80211_key *);
|
|
|
|
static int rsu_reinit_static_keys(struct rsu_softc *);
|
|
|
|
static int rsu_delete_key(struct rsu_softc *sc, ieee80211_keyix);
|
|
|
|
static void rsu_delete_key_pair_cb(void *, int);
|
2016-11-27 12:03:34 +00:00
|
|
|
static int rsu_site_survey(struct rsu_softc *,
|
|
|
|
struct ieee80211_scan_ssid *);
|
2013-07-30 02:07:57 +00:00
|
|
|
static int rsu_join_bss(struct rsu_softc *, struct ieee80211_node *);
|
|
|
|
static int rsu_disconnect(struct rsu_softc *);
|
2015-09-30 05:19:16 +00:00
|
|
|
static int rsu_hwrssi_to_rssi(struct rsu_softc *, int hw_rssi);
|
2013-07-30 02:07:57 +00:00
|
|
|
static void rsu_event_survey(struct rsu_softc *, uint8_t *, int);
|
|
|
|
static void rsu_event_join_bss(struct rsu_softc *, uint8_t *, int);
|
|
|
|
static void rsu_rx_event(struct rsu_softc *, uint8_t, uint8_t *, int);
|
|
|
|
static void rsu_rx_multi_event(struct rsu_softc *, uint8_t *, int);
|
|
|
|
static int8_t rsu_get_rssi(struct rsu_softc *, int, void *);
|
2016-12-03 16:02:53 +00:00
|
|
|
static struct mbuf * rsu_rx_copy_to_mbuf(struct rsu_softc *,
|
|
|
|
struct r92s_rx_stat *, int);
|
2016-12-10 13:30:16 +00:00
|
|
|
static uint32_t rsu_get_tsf_low(struct rsu_softc *);
|
|
|
|
static uint32_t rsu_get_tsf_high(struct rsu_softc *);
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
static struct ieee80211_node * rsu_rx_frame(struct rsu_softc *, struct mbuf *);
|
2015-09-30 05:19:16 +00:00
|
|
|
static struct mbuf * rsu_rx_multi_frame(struct rsu_softc *, uint8_t *, int);
|
2013-07-30 02:07:57 +00:00
|
|
|
static struct mbuf *
|
2015-09-30 05:19:16 +00:00
|
|
|
rsu_rxeof(struct usb_xfer *, struct rsu_data *);
|
2013-07-30 02:07:57 +00:00
|
|
|
static void rsu_txeof(struct usb_xfer *, struct rsu_data *);
|
|
|
|
static int rsu_raw_xmit(struct ieee80211_node *, struct mbuf *,
|
|
|
|
const struct ieee80211_bpf_params *);
|
2016-12-10 18:47:13 +00:00
|
|
|
static void rsu_rxfilter_init(struct rsu_softc *);
|
|
|
|
static void rsu_rxfilter_set(struct rsu_softc *, uint32_t, uint32_t);
|
|
|
|
static void rsu_rxfilter_refresh(struct rsu_softc *);
|
2016-12-10 22:31:49 +00:00
|
|
|
static int rsu_init(struct rsu_softc *);
|
2013-07-30 02:07:57 +00:00
|
|
|
static int rsu_tx_start(struct rsu_softc *, struct ieee80211_node *,
|
2014-05-21 16:52:55 +00:00
|
|
|
struct mbuf *, struct rsu_data *);
|
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 rsu_transmit(struct ieee80211com *, struct mbuf *);
|
|
|
|
static void rsu_start(struct rsu_softc *);
|
2015-09-21 02:30:22 +00:00
|
|
|
static void _rsu_start(struct rsu_softc *);
|
2016-12-11 17:15:25 +00:00
|
|
|
static int rsu_ioctl_net(struct ieee80211com *, u_long, 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 rsu_parent(struct ieee80211com *);
|
|
|
|
static void rsu_stop(struct rsu_softc *);
|
2015-09-17 03:01:19 +00:00
|
|
|
static void rsu_ms_delay(struct rsu_softc *, int);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
static device_method_t rsu_methods[] = {
|
|
|
|
DEVMETHOD(device_probe, rsu_match),
|
|
|
|
DEVMETHOD(device_attach, rsu_attach),
|
|
|
|
DEVMETHOD(device_detach, rsu_detach),
|
|
|
|
|
|
|
|
DEVMETHOD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t rsu_driver = {
|
|
|
|
.name = "rsu",
|
|
|
|
.methods = rsu_methods,
|
|
|
|
.size = sizeof(struct rsu_softc)
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t rsu_devclass;
|
|
|
|
|
|
|
|
DRIVER_MODULE(rsu, uhub, rsu_driver, rsu_devclass, NULL, 0);
|
|
|
|
MODULE_DEPEND(rsu, wlan, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(rsu, usb, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(rsu, firmware, 1, 1, 1);
|
|
|
|
MODULE_VERSION(rsu, 1);
|
2015-12-11 05:28:00 +00:00
|
|
|
USB_PNP_HOST_INFO(rsu_devs);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2016-05-26 16:39:11 +00:00
|
|
|
static const uint8_t rsu_chan_2ghz[] =
|
|
|
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
|
|
|
|
|
2014-06-04 09:18:13 +00:00
|
|
|
static uint8_t rsu_wme_ac_xfer_map[4] = {
|
|
|
|
[WME_AC_BE] = RSU_BULK_TX_BE_BK,
|
|
|
|
[WME_AC_BK] = RSU_BULK_TX_BE_BK,
|
|
|
|
[WME_AC_VI] = RSU_BULK_TX_VI_VO,
|
|
|
|
[WME_AC_VO] = RSU_BULK_TX_VI_VO,
|
|
|
|
};
|
|
|
|
|
2015-09-17 03:19:09 +00:00
|
|
|
/* XXX hard-coded */
|
|
|
|
#define RSU_H2C_ENDPOINT 3
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static const struct usb_config rsu_config[RSU_N_TRANSFER] = {
|
|
|
|
[RSU_BULK_RX] = {
|
|
|
|
.type = UE_BULK,
|
|
|
|
.endpoint = UE_ADDR_ANY,
|
|
|
|
.direction = UE_DIR_IN,
|
|
|
|
.bufsize = RSU_RXBUFSZ,
|
|
|
|
.flags = {
|
|
|
|
.pipe_bof = 1,
|
|
|
|
.short_xfer_ok = 1
|
|
|
|
},
|
|
|
|
.callback = rsu_bulk_rx_callback
|
|
|
|
},
|
2014-06-04 09:18:13 +00:00
|
|
|
[RSU_BULK_TX_BE_BK] = {
|
2013-07-30 02:07:57 +00:00
|
|
|
.type = UE_BULK,
|
|
|
|
.endpoint = 0x06,
|
|
|
|
.direction = UE_DIR_OUT,
|
|
|
|
.bufsize = RSU_TXBUFSZ,
|
|
|
|
.flags = {
|
|
|
|
.ext_buffer = 1,
|
|
|
|
.pipe_bof = 1,
|
|
|
|
.force_short_xfer = 1
|
|
|
|
},
|
2014-06-04 09:18:13 +00:00
|
|
|
.callback = rsu_bulk_tx_callback_be_bk,
|
2013-07-30 02:07:57 +00:00
|
|
|
.timeout = RSU_TX_TIMEOUT
|
|
|
|
},
|
2014-06-04 09:18:13 +00:00
|
|
|
[RSU_BULK_TX_VI_VO] = {
|
2013-07-30 02:07:57 +00:00
|
|
|
.type = UE_BULK,
|
|
|
|
.endpoint = 0x04,
|
|
|
|
.direction = UE_DIR_OUT,
|
|
|
|
.bufsize = RSU_TXBUFSZ,
|
|
|
|
.flags = {
|
|
|
|
.ext_buffer = 1,
|
|
|
|
.pipe_bof = 1,
|
|
|
|
.force_short_xfer = 1
|
|
|
|
},
|
2014-06-04 09:18:13 +00:00
|
|
|
.callback = rsu_bulk_tx_callback_vi_vo,
|
2013-07-30 02:07:57 +00:00
|
|
|
.timeout = RSU_TX_TIMEOUT
|
|
|
|
},
|
2015-09-17 03:19:09 +00:00
|
|
|
[RSU_BULK_TX_H2C] = {
|
|
|
|
.type = UE_BULK,
|
|
|
|
.endpoint = 0x0d,
|
|
|
|
.direction = UE_DIR_OUT,
|
|
|
|
.bufsize = RSU_TXBUFSZ,
|
|
|
|
.flags = {
|
|
|
|
.ext_buffer = 1,
|
|
|
|
.pipe_bof = 1,
|
|
|
|
.short_xfer_ok = 1
|
|
|
|
},
|
|
|
|
.callback = rsu_bulk_tx_callback_h2c,
|
|
|
|
.timeout = RSU_TX_TIMEOUT
|
|
|
|
},
|
2013-07-30 02:07:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_match(device_t self)
|
|
|
|
{
|
|
|
|
struct usb_attach_arg *uaa = device_get_ivars(self);
|
|
|
|
|
|
|
|
if (uaa->usb_mode != USB_MODE_HOST ||
|
|
|
|
uaa->info.bIfaceIndex != 0 ||
|
|
|
|
uaa->info.bConfigIndex != 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
return (usbd_lookup_id_by_uaa(rsu_devs, sizeof(rsu_devs), uaa));
|
|
|
|
}
|
|
|
|
|
2015-09-13 19:17:26 +00:00
|
|
|
static int
|
|
|
|
rsu_send_mgmt(struct ieee80211_node *ni, int type, int arg)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (ENOTSUP);
|
|
|
|
}
|
|
|
|
|
2015-09-17 03:13:01 +00:00
|
|
|
static void
|
|
|
|
rsu_update_chw(struct ieee80211com *ic)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-09-22 02:57:18 +00:00
|
|
|
/*
|
|
|
|
* notification from net80211 that it'd like to do A-MPDU on the given TID.
|
|
|
|
*
|
|
|
|
* Note: this actually hangs traffic at the present moment, so don't use it.
|
|
|
|
* The firmware debug does indiciate it's sending and establishing a TX AMPDU
|
|
|
|
* session, but then no traffic flows.
|
|
|
|
*/
|
2015-09-17 03:13:01 +00:00
|
|
|
static int
|
|
|
|
rsu_ampdu_enable(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap)
|
|
|
|
{
|
2015-09-22 02:57:18 +00:00
|
|
|
#if 0
|
|
|
|
struct rsu_softc *sc = ni->ni_ic->ic_softc;
|
|
|
|
struct r92s_add_ba_req req;
|
2015-09-17 03:13:01 +00:00
|
|
|
|
2015-09-22 02:57:18 +00:00
|
|
|
/* Don't enable if it's requested or running */
|
|
|
|
if (IEEE80211_AMPDU_REQUESTED(tap))
|
|
|
|
return (0);
|
|
|
|
if (IEEE80211_AMPDU_RUNNING(tap))
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
/* We've decided to send addba; so send it */
|
|
|
|
req.tid = htole32(tap->txa_tid);
|
|
|
|
|
|
|
|
/* Attempt net80211 state */
|
|
|
|
if (ieee80211_ampdu_tx_request_ext(ni, tap->txa_tid) != 1)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
/* Send the firmware command */
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_AMPDU, "%s: establishing AMPDU TX for TID %d\n",
|
|
|
|
__func__,
|
|
|
|
tap->txa_tid);
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
if (rsu_fw_cmd(sc, R92S_CMD_ADDBA_REQ, &req, sizeof(req)) != 1) {
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
/* Mark failure */
|
|
|
|
(void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
|
|
|
/* Mark success; we don't get any further notifications */
|
|
|
|
(void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 1);
|
|
|
|
#endif
|
|
|
|
/* Return 0, we're driving this ourselves */
|
2015-09-17 03:13:01 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_wme_update(struct ieee80211com *ic)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Firmware handles this; not our problem */
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static int
|
|
|
|
rsu_attach(device_t self)
|
|
|
|
{
|
|
|
|
struct usb_attach_arg *uaa = device_get_ivars(self);
|
|
|
|
struct rsu_softc *sc = device_get_softc(self);
|
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;
|
2013-07-30 02:07:57 +00:00
|
|
|
int error;
|
2016-01-07 18:41:03 +00:00
|
|
|
uint8_t iface_index;
|
2015-09-17 03:08:02 +00:00
|
|
|
struct usb_interface *iface;
|
2015-09-29 06:56:00 +00:00
|
|
|
const char *rft;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
device_set_usb_desc(self);
|
|
|
|
sc->sc_udev = uaa->device;
|
|
|
|
sc->sc_dev = self;
|
2016-12-11 17:15:25 +00:00
|
|
|
sc->sc_rx_checksum_enable = 1;
|
2015-09-18 04:12:11 +00:00
|
|
|
if (rsu_enable_11n)
|
|
|
|
sc->sc_ht = !! (USB_GET_DRIVER_INFO(uaa) & RSU_HT_SUPPORTED);
|
2015-09-17 03:08:02 +00:00
|
|
|
|
|
|
|
/* Get number of endpoints */
|
|
|
|
iface = usbd_get_iface(sc->sc_udev, 0);
|
|
|
|
sc->sc_nendpoints = iface->idesc->bNumEndpoints;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2015-09-17 03:42:18 +00:00
|
|
|
/* Endpoints are hard-coded for now, so enforce 4-endpoint only */
|
|
|
|
if (sc->sc_nendpoints != 4) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"the driver currently only supports 4-endpoint devices\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
mtx_init(&sc->sc_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK,
|
|
|
|
MTX_DEF);
|
2016-12-06 00:13:49 +00:00
|
|
|
RSU_DELKEY_BMAP_LOCK_INIT(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_task, 0,
|
|
|
|
rsu_calib_task, sc);
|
2016-12-06 00:13:49 +00:00
|
|
|
TASK_INIT(&sc->del_key_task, 0, rsu_delete_key_pair_cb, sc);
|
2015-09-21 02:30:22 +00:00
|
|
|
TASK_INIT(&sc->tx_task, 0, rsu_tx_task, 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
|
|
|
mbufq_init(&sc->sc_snd, ifqmaxlen);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2014-05-22 06:28:09 +00:00
|
|
|
/* Allocate Tx/Rx buffers. */
|
|
|
|
error = rsu_alloc_rx_list(sc);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not allocate Rx buffers\n");
|
|
|
|
goto fail_usb;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = rsu_alloc_tx_list(sc);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not allocate Tx buffers\n");
|
|
|
|
rsu_free_rx_list(sc);
|
|
|
|
goto fail_usb;
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
iface_index = 0;
|
|
|
|
error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer,
|
|
|
|
rsu_config, RSU_N_TRANSFER, sc, &sc->sc_mtx);
|
|
|
|
if (error) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate USB transfers, err=%s\n",
|
|
|
|
usbd_errstr(error));
|
2013-07-31 06:05:34 +00:00
|
|
|
goto fail_usb;
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
/* Read chip revision. */
|
|
|
|
sc->cut = MS(rsu_read_4(sc, R92S_PMC_FSM), R92S_PMC_FSM_CUT);
|
|
|
|
if (sc->cut != 3)
|
|
|
|
sc->cut = (sc->cut >> 1) + 1;
|
|
|
|
error = rsu_read_rom(sc);
|
2015-01-03 11:04:17 +00:00
|
|
|
RSU_UNLOCK(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(self, "could not read ROM\n");
|
2013-07-31 06:05:34 +00:00
|
|
|
goto fail_rom;
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
2015-09-29 06:56:00 +00:00
|
|
|
|
|
|
|
/* Figure out TX/RX streams */
|
|
|
|
switch (sc->rom[84]) {
|
|
|
|
case 0x0:
|
|
|
|
sc->sc_rftype = RTL8712_RFCONFIG_1T1R;
|
|
|
|
sc->sc_nrxstream = 1;
|
|
|
|
sc->sc_ntxstream = 1;
|
|
|
|
rft = "1T1R";
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
sc->sc_rftype = RTL8712_RFCONFIG_1T2R;
|
|
|
|
sc->sc_nrxstream = 2;
|
|
|
|
sc->sc_ntxstream = 1;
|
|
|
|
rft = "1T2R";
|
|
|
|
break;
|
|
|
|
case 0x2:
|
|
|
|
sc->sc_rftype = RTL8712_RFCONFIG_2T2R;
|
|
|
|
sc->sc_nrxstream = 2;
|
|
|
|
sc->sc_ntxstream = 2;
|
|
|
|
rft = "2T2R";
|
|
|
|
break;
|
2017-01-09 21:46:24 +00:00
|
|
|
case 0x3: /* "green" NIC */
|
|
|
|
sc->sc_rftype = RTL8712_RFCONFIG_1T2R;
|
|
|
|
sc->sc_nrxstream = 2;
|
|
|
|
sc->sc_ntxstream = 1;
|
|
|
|
rft = "1T2R ('green')";
|
|
|
|
break;
|
2015-09-29 06:56:00 +00:00
|
|
|
default:
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: unknown board type (rfconfig=0x%02x)\n",
|
|
|
|
__func__,
|
|
|
|
sc->rom[84]);
|
|
|
|
goto fail_rom;
|
|
|
|
}
|
|
|
|
|
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_ADDR_COPY(ic->ic_macaddr, &sc->rom[0x12]);
|
2015-09-29 06:56:00 +00:00
|
|
|
device_printf(self, "MAC/BB RTL8712 cut %d %s\n", sc->cut, rft);
|
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
|
|
|
|
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(self);
|
2013-07-30 02:07:57 +00:00
|
|
|
ic->ic_phytype = IEEE80211_T_OFDM; /* Not only, but not used. */
|
|
|
|
ic->ic_opmode = IEEE80211_M_STA; /* Default to BSS mode. */
|
|
|
|
|
|
|
|
/* Set device capabilities. */
|
|
|
|
ic->ic_caps =
|
|
|
|
IEEE80211_C_STA | /* station mode */
|
2016-12-10 18:47:13 +00:00
|
|
|
IEEE80211_C_MONITOR | /* monitor mode supported */
|
2015-09-12 23:10:34 +00:00
|
|
|
#if 0
|
2013-07-30 02:07:57 +00:00
|
|
|
IEEE80211_C_BGSCAN | /* Background scan. */
|
2015-09-12 23:10:34 +00:00
|
|
|
#endif
|
2013-07-30 02:07:57 +00:00
|
|
|
IEEE80211_C_SHPREAMBLE | /* Short preamble supported. */
|
2015-09-17 04:45:29 +00:00
|
|
|
IEEE80211_C_WME | /* WME/QoS */
|
2013-07-30 02:07:57 +00:00
|
|
|
IEEE80211_C_SHSLOT | /* Short slot time supported. */
|
|
|
|
IEEE80211_C_WPA; /* WPA/RSN. */
|
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
ic->ic_cryptocaps =
|
|
|
|
IEEE80211_CRYPTO_WEP |
|
|
|
|
IEEE80211_CRYPTO_TKIP |
|
|
|
|
IEEE80211_CRYPTO_AES_CCM;
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Check if HT support is present. */
|
2015-09-18 04:12:11 +00:00
|
|
|
if (sc->sc_ht) {
|
|
|
|
device_printf(sc->sc_dev, "%s: enabling 11n\n", __func__);
|
|
|
|
|
|
|
|
/* Enable basic HT */
|
|
|
|
ic->ic_htcaps = IEEE80211_HTC_HT |
|
2016-04-06 00:41:06 +00:00
|
|
|
#if 0
|
2015-09-18 04:12:11 +00:00
|
|
|
IEEE80211_HTC_AMPDU |
|
2016-04-06 00:41:06 +00:00
|
|
|
#endif
|
2015-09-18 04:12:11 +00:00
|
|
|
IEEE80211_HTC_AMSDU |
|
|
|
|
IEEE80211_HTCAP_MAXAMSDU_3839 |
|
|
|
|
IEEE80211_HTCAP_SMPS_OFF;
|
|
|
|
ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40;
|
|
|
|
|
|
|
|
/* set number of spatial streams */
|
2015-09-29 06:56:00 +00:00
|
|
|
ic->ic_txstream = sc->sc_ntxstream;
|
|
|
|
ic->ic_rxstream = sc->sc_nrxstream;
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
2016-11-27 12:03:34 +00:00
|
|
|
ic->ic_flags_ext |= IEEE80211_FEXT_SCAN_OFFLOAD;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2016-05-26 16:39:11 +00:00
|
|
|
rsu_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
|
|
|
|
ic->ic_channels);
|
2013-07-30 02:07:57 +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);
|
2013-07-30 02:07:57 +00:00
|
|
|
ic->ic_raw_xmit = rsu_raw_xmit;
|
|
|
|
ic->ic_scan_start = rsu_scan_start;
|
|
|
|
ic->ic_scan_end = rsu_scan_end;
|
2016-05-26 16:39:11 +00:00
|
|
|
ic->ic_getradiocaps = rsu_getradiocaps;
|
2013-07-30 02:07:57 +00:00
|
|
|
ic->ic_set_channel = rsu_set_channel;
|
2016-11-27 12:03:34 +00:00
|
|
|
ic->ic_scan_curchan = rsu_scan_curchan;
|
|
|
|
ic->ic_scan_mindwell = rsu_scan_mindwell;
|
2013-07-30 02:07:57 +00:00
|
|
|
ic->ic_vap_create = rsu_vap_create;
|
|
|
|
ic->ic_vap_delete = rsu_vap_delete;
|
2016-12-10 18:47:13 +00:00
|
|
|
ic->ic_update_promisc = rsu_update_promisc;
|
2013-07-30 02:07:57 +00:00
|
|
|
ic->ic_update_mcast = rsu_update_mcast;
|
2016-12-11 17:15:25 +00:00
|
|
|
ic->ic_ioctl = rsu_ioctl_net;
|
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 = rsu_parent;
|
|
|
|
ic->ic_transmit = rsu_transmit;
|
2015-09-13 19:17:26 +00:00
|
|
|
ic->ic_send_mgmt = rsu_send_mgmt;
|
2015-09-17 03:13:01 +00:00
|
|
|
ic->ic_update_chw = rsu_update_chw;
|
|
|
|
ic->ic_ampdu_enable = rsu_ampdu_enable;
|
|
|
|
ic->ic_wme.wme_update = rsu_wme_update;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr,
|
|
|
|
sizeof(sc->sc_txtap), RSU_TX_RADIOTAP_PRESENT,
|
|
|
|
&sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
|
|
|
|
RSU_RX_RADIOTAP_PRESENT);
|
|
|
|
|
|
|
|
if (bootverbose)
|
|
|
|
ieee80211_announce(ic);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
2013-07-31 06:05:34 +00:00
|
|
|
fail_rom:
|
|
|
|
usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER);
|
|
|
|
fail_usb:
|
|
|
|
mtx_destroy(&sc->sc_mtx);
|
2013-07-30 02:07:57 +00:00
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_detach(device_t self)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = device_get_softc(self);
|
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;
|
2013-07-30 02:07:57 +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
|
|
|
rsu_stop(sc);
|
2015-09-26 22:20:30 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER);
|
2015-09-21 02:12:01 +00:00
|
|
|
|
2015-09-26 22:20:30 +00:00
|
|
|
/*
|
|
|
|
* Free buffers /before/ we detach from net80211, else node
|
|
|
|
* references to destroyed vaps will lead to a panic.
|
|
|
|
*/
|
|
|
|
/* Free Tx/Rx buffers. */
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
rsu_free_tx_list(sc);
|
|
|
|
rsu_free_rx_list(sc);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
2015-09-21 02:12:01 +00:00
|
|
|
/* Frames are freed; detach from net80211 */
|
2013-07-30 02:07:57 +00:00
|
|
|
ieee80211_ifdetach(ic);
|
|
|
|
|
|
|
|
taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task);
|
2016-12-06 00:13:49 +00:00
|
|
|
taskqueue_drain(taskqueue_thread, &sc->del_key_task);
|
2015-09-21 02:30:22 +00:00
|
|
|
taskqueue_drain(taskqueue_thread, &sc->tx_task);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
RSU_DELKEY_BMAP_LOCK_DESTROY(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
mtx_destroy(&sc->sc_mtx);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static usb_error_t
|
|
|
|
rsu_do_request(struct rsu_softc *sc, struct usb_device_request *req,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
usb_error_t err;
|
|
|
|
int ntries = 10;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
while (ntries--) {
|
|
|
|
err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx,
|
|
|
|
req, data, 0, NULL, 250 /* ms */);
|
2014-05-20 12:22:53 +00:00
|
|
|
if (err == 0 || err == USB_ERR_NOT_CONFIGURED)
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
2016-12-10 20:19:57 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_USB,
|
|
|
|
"Control request failed, %s (retries left: %d)\n",
|
|
|
|
usbd_errstr(err), ntries);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 10);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ieee80211vap *
|
|
|
|
rsu_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])
|
|
|
|
{
|
2016-12-11 17:15:25 +00:00
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct rsu_vap *uvp;
|
|
|
|
struct ieee80211vap *vap;
|
2016-12-11 17:15:25 +00:00
|
|
|
struct ifnet *ifp;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
|
|
|
|
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
|
|
|
uvp = malloc(sizeof(struct rsu_vap), M_80211_VAP, M_WAITOK | M_ZERO);
|
2013-07-30 02:07:57 +00:00
|
|
|
vap = &uvp->vap;
|
2013-11-06 12:57:01 +00:00
|
|
|
|
|
|
|
if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
|
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
|
|
|
flags, bssid) != 0) {
|
2013-11-06 12:57:01 +00:00
|
|
|
/* out of memory */
|
|
|
|
free(uvp, M_80211_VAP);
|
|
|
|
return (NULL);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2016-12-11 17:15:25 +00:00
|
|
|
ifp = vap->iv_ifp;
|
|
|
|
ifp->if_capabilities = IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
if (sc->sc_rx_checksum_enable)
|
|
|
|
ifp->if_capenable |= IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* override state transition machine */
|
|
|
|
uvp->newstate = vap->iv_newstate;
|
2016-12-10 18:47:13 +00:00
|
|
|
if (opmode == IEEE80211_M_MONITOR)
|
|
|
|
vap->iv_newstate = rsu_monitor_newstate;
|
|
|
|
else
|
|
|
|
vap->iv_newstate = rsu_newstate;
|
2016-12-06 00:13:49 +00:00
|
|
|
vap->iv_key_alloc = rsu_key_alloc;
|
|
|
|
vap->iv_key_set = rsu_key_set;
|
|
|
|
vap->iv_key_delete = rsu_key_delete;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2015-09-18 05:59:15 +00:00
|
|
|
/* Limits from the r92su driver */
|
|
|
|
vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_16;
|
|
|
|
vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_32K;
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* complete setup */
|
|
|
|
ieee80211_vap_attach(vap, ieee80211_media_change,
|
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_media_status, mac);
|
2013-07-30 02:07:57 +00:00
|
|
|
ic->ic_opmode = opmode;
|
|
|
|
|
|
|
|
return (vap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_vap_delete(struct ieee80211vap *vap)
|
|
|
|
{
|
|
|
|
struct rsu_vap *uvp = RSU_VAP(vap);
|
|
|
|
|
|
|
|
ieee80211_vap_detach(vap);
|
|
|
|
free(uvp, M_80211_VAP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_scan_start(struct ieee80211com *ic)
|
|
|
|
{
|
2015-08-20 05:13:54 +00:00
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
2016-11-27 12:03:34 +00:00
|
|
|
struct ieee80211_scan_state *ss = ic->ic_scan;
|
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&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
|
|
|
int error;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Scanning is done by the firmware. */
|
|
|
|
RSU_LOCK(sc);
|
2016-11-27 12:03:34 +00:00
|
|
|
sc->sc_active_scan = !!(ss->ss_flags & IEEE80211_SCAN_ACTIVE);
|
|
|
|
/* XXX TODO: force awake if in network-sleep? */
|
|
|
|
error = rsu_site_survey(sc, ss->ss_nssid > 0 ? &ss->ss_ssid[0] : NULL);
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(sc);
|
2016-11-27 12:03:34 +00:00
|
|
|
if (error != 0) {
|
2013-07-30 02:07:57 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not send site survey command\n");
|
2016-11-27 12:03:34 +00:00
|
|
|
ieee80211_cancel_scan(vap);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_scan_end(struct ieee80211com *ic)
|
|
|
|
{
|
|
|
|
/* Nothing to do here. */
|
|
|
|
}
|
|
|
|
|
2016-05-26 16:39:11 +00:00
|
|
|
static void
|
|
|
|
rsu_getradiocaps(struct ieee80211com *ic,
|
|
|
|
int maxchans, int *nchans, struct ieee80211_channel chans[])
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
|
|
|
uint8_t bands[IEEE80211_MODE_BYTES];
|
|
|
|
|
|
|
|
/* Set supported .11b and .11g rates. */
|
|
|
|
memset(bands, 0, sizeof(bands));
|
|
|
|
setbit(bands, IEEE80211_MODE_11B);
|
|
|
|
setbit(bands, IEEE80211_MODE_11G);
|
|
|
|
if (sc->sc_ht)
|
|
|
|
setbit(bands, IEEE80211_MODE_11NG);
|
|
|
|
ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
|
2017-01-02 16:58:55 +00:00
|
|
|
rsu_chan_2ghz, nitems(rsu_chan_2ghz), bands,
|
|
|
|
(ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) != 0);
|
2016-05-26 16:39:11 +00:00
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static void
|
2016-12-10 18:47:13 +00:00
|
|
|
rsu_set_channel(struct ieee80211com *ic)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
2016-12-10 18:47:13 +00:00
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only need to set the channel in Monitor mode. AP scanning and auth
|
|
|
|
* are already taken care of by their respective firmware commands.
|
|
|
|
*/
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_MONITOR) {
|
|
|
|
struct r92s_set_channel cmd;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
cmd.channel = IEEE80211_CHAN2IEEE(ic->ic_curchan);
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_CHANNEL, &cmd,
|
|
|
|
sizeof(cmd));
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: error %d setting channel\n", __func__,
|
|
|
|
error);
|
|
|
|
}
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
2016-11-27 12:03:34 +00:00
|
|
|
static void
|
|
|
|
rsu_scan_curchan(struct ieee80211_scan_state *ss, unsigned long maxdwell)
|
|
|
|
{
|
|
|
|
/* Scan is done in rsu_scan_start(). */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by the net80211 framework to indicate
|
|
|
|
* the minimum dwell time has been met, terminate the scan.
|
|
|
|
* We don't actually terminate the scan as the firmware will notify
|
|
|
|
* us when it's finished and we have no way to interrupt it.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
rsu_scan_mindwell(struct ieee80211_scan_state *ss)
|
|
|
|
{
|
|
|
|
/* NB: don't try to abort scan; wait for firmware to finish */
|
|
|
|
}
|
|
|
|
|
2016-12-10 18:47:13 +00:00
|
|
|
static void
|
|
|
|
rsu_update_promisc(struct ieee80211com *ic)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
if (sc->sc_running)
|
|
|
|
rsu_rxfilter_refresh(sc);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
2016-11-27 18:06:03 +00:00
|
|
|
/*
|
|
|
|
* The same as rtwn_get_multi_pos() / rtwn_set_multi().
|
|
|
|
*/
|
|
|
|
static uint8_t
|
|
|
|
rsu_get_multi_pos(const uint8_t maddr[])
|
|
|
|
{
|
|
|
|
uint64_t mask = 0x00004d101df481b4;
|
|
|
|
uint8_t pos = 0x27; /* initial value */
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < IEEE80211_ADDR_LEN; i++)
|
|
|
|
for (j = (i == 0) ? 1 : 0; j < 8; j++)
|
|
|
|
if ((maddr[i] >> j) & 1)
|
|
|
|
pos ^= (mask >> (i * 8 + j - 1));
|
|
|
|
|
|
|
|
pos &= 0x3f;
|
|
|
|
|
|
|
|
return (pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_set_multi(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
|
|
|
uint32_t mfilt[2];
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
/* general structure was copied from ath(4). */
|
|
|
|
if (ic->ic_allmulti == 0) {
|
|
|
|
struct ieee80211vap *vap;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct ifmultiaddr *ifma;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Merge multicast addresses to form the hardware filter.
|
|
|
|
*/
|
|
|
|
mfilt[0] = mfilt[1] = 0;
|
|
|
|
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
|
|
|
|
ifp = vap->iv_ifp;
|
|
|
|
if_maddr_rlock(ifp);
|
|
|
|
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
|
|
|
caddr_t dl;
|
|
|
|
uint8_t pos;
|
|
|
|
|
|
|
|
dl = LLADDR((struct sockaddr_dl *)
|
|
|
|
ifma->ifma_addr);
|
|
|
|
pos = rsu_get_multi_pos(dl);
|
|
|
|
|
|
|
|
mfilt[pos / 32] |= (1 << (pos % 32));
|
|
|
|
}
|
|
|
|
if_maddr_runlock(ifp);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
mfilt[0] = mfilt[1] = ~0;
|
|
|
|
|
|
|
|
rsu_write_4(sc, R92S_MAR + 0, mfilt[0]);
|
|
|
|
rsu_write_4(sc, R92S_MAR + 4, mfilt[1]);
|
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_STATE, "%s: MC filter %08x:%08x\n",
|
|
|
|
__func__, mfilt[0], mfilt[1]);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static void
|
2015-05-25 19:53:29 +00:00
|
|
|
rsu_update_mcast(struct ieee80211com *ic)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
2016-11-27 18:06:03 +00:00
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
if (sc->sc_running)
|
|
|
|
rsu_set_multi(sc);
|
|
|
|
RSU_UNLOCK(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_alloc_list(struct rsu_softc *sc, struct rsu_data data[],
|
|
|
|
int ndata, int maxsz)
|
|
|
|
{
|
|
|
|
int i, error;
|
|
|
|
|
|
|
|
for (i = 0; i < ndata; i++) {
|
|
|
|
struct rsu_data *dp = &data[i];
|
|
|
|
dp->sc = sc;
|
|
|
|
dp->m = NULL;
|
|
|
|
dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT);
|
|
|
|
if (dp->buf == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not allocate buffer\n");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
dp->ni = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
fail:
|
|
|
|
rsu_free_list(sc, data, ndata);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_alloc_rx_list(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
int error, i;
|
|
|
|
|
|
|
|
error = rsu_alloc_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT,
|
|
|
|
RSU_RXBUFSZ);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
STAILQ_INIT(&sc->sc_rx_active);
|
|
|
|
STAILQ_INIT(&sc->sc_rx_inactive);
|
|
|
|
|
|
|
|
for (i = 0; i < RSU_RX_LIST_COUNT; i++)
|
|
|
|
STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_alloc_tx_list(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
int error, i;
|
|
|
|
|
|
|
|
error = rsu_alloc_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT,
|
|
|
|
RSU_TXBUFSZ);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
STAILQ_INIT(&sc->sc_tx_inactive);
|
2014-05-21 16:52:55 +00:00
|
|
|
|
2014-06-04 09:18:13 +00:00
|
|
|
for (i = 0; i != RSU_N_TRANSFER; i++) {
|
2014-05-21 16:52:55 +00:00
|
|
|
STAILQ_INIT(&sc->sc_tx_active[i]);
|
|
|
|
STAILQ_INIT(&sc->sc_tx_pending[i]);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
for (i = 0; i < RSU_TX_LIST_COUNT; i++) {
|
|
|
|
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], next);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_free_tx_list(struct rsu_softc *sc)
|
|
|
|
{
|
2014-05-22 06:28:09 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* prevent further allocations from TX list(s) */
|
|
|
|
STAILQ_INIT(&sc->sc_tx_inactive);
|
|
|
|
|
2014-06-04 09:18:13 +00:00
|
|
|
for (i = 0; i != RSU_N_TRANSFER; i++) {
|
2014-05-22 06:28:09 +00:00
|
|
|
STAILQ_INIT(&sc->sc_tx_active[i]);
|
|
|
|
STAILQ_INIT(&sc->sc_tx_pending[i]);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_free_list(sc, sc->sc_tx, RSU_TX_LIST_COUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_free_rx_list(struct rsu_softc *sc)
|
|
|
|
{
|
2014-05-22 06:28:09 +00:00
|
|
|
/* prevent further allocations from RX list(s) */
|
|
|
|
STAILQ_INIT(&sc->sc_rx_inactive);
|
|
|
|
STAILQ_INIT(&sc->sc_rx_active);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_free_list(sc, sc->sc_rx, RSU_RX_LIST_COUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_free_list(struct rsu_softc *sc, struct rsu_data data[], int ndata)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ndata; i++) {
|
|
|
|
struct rsu_data *dp = &data[i];
|
|
|
|
|
|
|
|
if (dp->buf != NULL) {
|
|
|
|
free(dp->buf, M_USBDEV);
|
|
|
|
dp->buf = NULL;
|
|
|
|
}
|
|
|
|
if (dp->ni != NULL) {
|
|
|
|
ieee80211_free_node(dp->ni);
|
|
|
|
dp->ni = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct rsu_data *
|
|
|
|
_rsu_getbuf(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
struct rsu_data *bf;
|
|
|
|
|
|
|
|
bf = STAILQ_FIRST(&sc->sc_tx_inactive);
|
|
|
|
if (bf != NULL)
|
|
|
|
STAILQ_REMOVE_HEAD(&sc->sc_tx_inactive, next);
|
|
|
|
else
|
|
|
|
bf = NULL;
|
2015-09-18 07:55:33 +00:00
|
|
|
return (bf);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct rsu_data *
|
|
|
|
rsu_getbuf(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
struct rsu_data *bf;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
bf = _rsu_getbuf(sc);
|
2015-09-21 02:12:01 +00:00
|
|
|
if (bf == NULL) {
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX, "%s: no buffers\n", __func__);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
return (bf);
|
|
|
|
}
|
|
|
|
|
2015-09-18 07:26:34 +00:00
|
|
|
static void
|
|
|
|
rsu_freebuf(struct rsu_softc *sc, struct rsu_data *bf)
|
|
|
|
{
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, bf, next);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static int
|
|
|
|
rsu_write_region_1(struct rsu_softc *sc, uint16_t addr, uint8_t *buf,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
usb_device_request_t req;
|
|
|
|
|
|
|
|
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
|
|
|
|
req.bRequest = R92S_REQ_REGS;
|
|
|
|
USETW(req.wValue, addr);
|
|
|
|
USETW(req.wIndex, 0);
|
|
|
|
USETW(req.wLength, len);
|
|
|
|
|
|
|
|
return (rsu_do_request(sc, &req, buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_write_1(struct rsu_softc *sc, uint16_t addr, uint8_t val)
|
|
|
|
{
|
|
|
|
rsu_write_region_1(sc, addr, &val, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_write_2(struct rsu_softc *sc, uint16_t addr, uint16_t val)
|
|
|
|
{
|
|
|
|
val = htole16(val);
|
|
|
|
rsu_write_region_1(sc, addr, (uint8_t *)&val, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_write_4(struct rsu_softc *sc, uint16_t addr, uint32_t val)
|
|
|
|
{
|
|
|
|
val = htole32(val);
|
|
|
|
rsu_write_region_1(sc, addr, (uint8_t *)&val, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_read_region_1(struct rsu_softc *sc, uint16_t addr, uint8_t *buf,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
usb_device_request_t req;
|
|
|
|
|
|
|
|
req.bmRequestType = UT_READ_VENDOR_DEVICE;
|
|
|
|
req.bRequest = R92S_REQ_REGS;
|
|
|
|
USETW(req.wValue, addr);
|
|
|
|
USETW(req.wIndex, 0);
|
|
|
|
USETW(req.wLength, len);
|
|
|
|
|
|
|
|
return (rsu_do_request(sc, &req, buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t
|
|
|
|
rsu_read_1(struct rsu_softc *sc, uint16_t addr)
|
|
|
|
{
|
|
|
|
uint8_t val;
|
|
|
|
|
|
|
|
if (rsu_read_region_1(sc, addr, &val, 1) != 0)
|
|
|
|
return (0xff);
|
|
|
|
return (val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t
|
|
|
|
rsu_read_2(struct rsu_softc *sc, uint16_t addr)
|
|
|
|
{
|
|
|
|
uint16_t val;
|
|
|
|
|
|
|
|
if (rsu_read_region_1(sc, addr, (uint8_t *)&val, 2) != 0)
|
|
|
|
return (0xffff);
|
|
|
|
return (le16toh(val));
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
rsu_read_4(struct rsu_softc *sc, uint16_t addr)
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
|
|
|
|
if (rsu_read_region_1(sc, addr, (uint8_t *)&val, 4) != 0)
|
|
|
|
return (0xffffffff);
|
|
|
|
return (le32toh(val));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_fw_iocmd(struct rsu_softc *sc, uint32_t iocmd)
|
|
|
|
{
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
rsu_write_4(sc, R92S_IOCMD_CTRL, iocmd);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
for (ntries = 0; ntries < 50; ntries++) {
|
|
|
|
if (rsu_read_4(sc, R92S_IOCMD_CTRL) == 0)
|
|
|
|
return (0);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
return (ETIMEDOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t
|
|
|
|
rsu_efuse_read_1(struct rsu_softc *sc, uint16_t addr)
|
|
|
|
{
|
|
|
|
uint32_t reg;
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
reg = rsu_read_4(sc, R92S_EFUSE_CTRL);
|
|
|
|
reg = RW(reg, R92S_EFUSE_CTRL_ADDR, addr);
|
|
|
|
reg &= ~R92S_EFUSE_CTRL_VALID;
|
|
|
|
rsu_write_4(sc, R92S_EFUSE_CTRL, reg);
|
|
|
|
/* Wait for read operation to complete. */
|
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
|
|
|
reg = rsu_read_4(sc, R92S_EFUSE_CTRL);
|
|
|
|
if (reg & R92S_EFUSE_CTRL_VALID)
|
|
|
|
return (MS(reg, R92S_EFUSE_CTRL_DATA));
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not read efuse byte at address 0x%x\n", addr);
|
|
|
|
return (0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_read_rom(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
uint8_t *rom = sc->rom;
|
|
|
|
uint16_t addr = 0;
|
|
|
|
uint32_t reg;
|
|
|
|
uint8_t off, msk;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Make sure that ROM type is eFuse and that autoload succeeded. */
|
|
|
|
reg = rsu_read_1(sc, R92S_EE_9346CR);
|
|
|
|
if ((reg & (R92S_9356SEL | R92S_EEPROM_EN)) != R92S_EEPROM_EN)
|
|
|
|
return (EIO);
|
|
|
|
|
|
|
|
/* Turn on 2.5V to prevent eFuse leakage. */
|
|
|
|
reg = rsu_read_1(sc, R92S_EFUSE_TEST + 3);
|
|
|
|
rsu_write_1(sc, R92S_EFUSE_TEST + 3, reg | 0x80);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_write_1(sc, R92S_EFUSE_TEST + 3, reg & ~0x80);
|
|
|
|
|
|
|
|
/* Read full ROM image. */
|
|
|
|
memset(&sc->rom, 0xff, sizeof(sc->rom));
|
|
|
|
while (addr < 512) {
|
|
|
|
reg = rsu_efuse_read_1(sc, addr);
|
|
|
|
if (reg == 0xff)
|
|
|
|
break;
|
|
|
|
addr++;
|
|
|
|
off = reg >> 4;
|
|
|
|
msk = reg & 0xf;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (msk & (1 << i))
|
|
|
|
continue;
|
|
|
|
rom[off * 8 + i * 2 + 0] =
|
|
|
|
rsu_efuse_read_1(sc, addr);
|
|
|
|
addr++;
|
|
|
|
rom[off * 8 + i * 2 + 1] =
|
|
|
|
rsu_efuse_read_1(sc, addr);
|
|
|
|
addr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef USB_DEBUG
|
2016-12-10 20:19:57 +00:00
|
|
|
if (rsu_debug & RSU_DEBUG_RESET) {
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Dump ROM content. */
|
|
|
|
printf("\n");
|
|
|
|
for (i = 0; i < sizeof(sc->rom); i++)
|
|
|
|
printf("%02x:", rom[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_fw_cmd(struct rsu_softc *sc, uint8_t code, void *buf, int len)
|
|
|
|
{
|
2015-09-17 03:19:09 +00:00
|
|
|
const uint8_t which = RSU_H2C_ENDPOINT;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct rsu_data *data;
|
|
|
|
struct r92s_tx_desc *txd;
|
|
|
|
struct r92s_fw_cmd_hdr *cmd;
|
2014-05-21 16:52:55 +00:00
|
|
|
int cmdsz;
|
|
|
|
int xferlen;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2015-09-18 07:55:33 +00:00
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
data = rsu_getbuf(sc);
|
|
|
|
if (data == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
|
2015-09-22 02:57:18 +00:00
|
|
|
/* Blank the entire payload, just to be safe */
|
|
|
|
memset(data->buf, '\0', RSU_TXBUFSZ);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Round-up command length to a multiple of 8 bytes. */
|
2015-09-22 02:57:18 +00:00
|
|
|
/* XXX TODO: is this required? */
|
2013-07-30 02:07:57 +00:00
|
|
|
cmdsz = (len + 7) & ~7;
|
|
|
|
|
|
|
|
xferlen = sizeof(*txd) + sizeof(*cmd) + cmdsz;
|
|
|
|
KASSERT(xferlen <= RSU_TXBUFSZ, ("%s: invalid length", __func__));
|
|
|
|
memset(data->buf, 0, xferlen);
|
|
|
|
|
|
|
|
/* Setup Tx descriptor. */
|
|
|
|
txd = (struct r92s_tx_desc *)data->buf;
|
|
|
|
txd->txdw0 = htole32(
|
|
|
|
SM(R92S_TXDW0_OFFSET, sizeof(*txd)) |
|
|
|
|
SM(R92S_TXDW0_PKTLEN, sizeof(*cmd) + cmdsz) |
|
|
|
|
R92S_TXDW0_OWN | R92S_TXDW0_FSG | R92S_TXDW0_LSG);
|
|
|
|
txd->txdw1 = htole32(SM(R92S_TXDW1_QSEL, R92S_TXDW1_QSEL_H2C));
|
|
|
|
|
|
|
|
/* Setup command header. */
|
|
|
|
cmd = (struct r92s_fw_cmd_hdr *)&txd[1];
|
|
|
|
cmd->len = htole16(cmdsz);
|
|
|
|
cmd->code = code;
|
|
|
|
cmd->seq = sc->cmd_seq;
|
|
|
|
sc->cmd_seq = (sc->cmd_seq + 1) & 0x7f;
|
|
|
|
|
|
|
|
/* Copy command payload. */
|
|
|
|
memcpy(&cmd[1], buf, len);
|
|
|
|
|
2015-09-13 04:12:51 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX | RSU_DEBUG_FWCMD,
|
2015-09-12 23:10:34 +00:00
|
|
|
"%s: Tx cmd code=0x%x len=0x%x\n",
|
|
|
|
__func__, code, cmdsz);
|
2013-07-30 02:07:57 +00:00
|
|
|
data->buflen = xferlen;
|
2014-05-21 16:52:55 +00:00
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next);
|
2014-06-04 09:18:13 +00:00
|
|
|
usbd_transfer_start(sc->sc_xfer[which]);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
|
|
|
static void
|
|
|
|
rsu_calib_task(void *arg, int pending __unused)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = arg;
|
2015-09-30 05:19:16 +00:00
|
|
|
#ifdef notyet
|
2013-07-30 02:07:57 +00:00
|
|
|
uint32_t reg;
|
2015-09-30 05:19:16 +00:00
|
|
|
#endif
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_CALIB, "%s: running calibration task\n",
|
|
|
|
__func__);
|
2014-06-04 09:18:13 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_LOCK(sc);
|
|
|
|
#ifdef notyet
|
|
|
|
/* Read WPS PBC status. */
|
|
|
|
rsu_write_1(sc, R92S_MAC_PINMUX_CTRL,
|
|
|
|
R92S_GPIOMUX_EN | SM(R92S_GPIOSEL_GPIO, R92S_GPIOSEL_GPIO_JTAG));
|
|
|
|
rsu_write_1(sc, R92S_GPIO_IO_SEL,
|
|
|
|
rsu_read_1(sc, R92S_GPIO_IO_SEL) & ~R92S_GPIO_WPS);
|
|
|
|
reg = rsu_read_1(sc, R92S_GPIO_CTRL);
|
|
|
|
if (reg != 0xff && (reg & R92S_GPIO_WPS))
|
2016-12-10 20:19:57 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_CALIB, "WPS PBC is pushed\n");
|
2013-07-30 02:07:57 +00:00
|
|
|
#endif
|
|
|
|
/* Read current signal level. */
|
|
|
|
if (rsu_fw_iocmd(sc, 0xf4000001) == 0) {
|
2015-09-30 05:19:16 +00:00
|
|
|
sc->sc_currssi = rsu_read_4(sc, R92S_IOCMD_DATA);
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_CALIB, "%s: RSSI=%d (%d)\n",
|
|
|
|
__func__, sc->sc_currssi,
|
|
|
|
rsu_hwrssi_to_rssi(sc, sc->sc_currssi));
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
2014-06-04 09:18:13 +00:00
|
|
|
if (sc->sc_calibrating)
|
|
|
|
taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task, hz);
|
|
|
|
RSU_UNLOCK(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
2015-09-21 02:30:22 +00:00
|
|
|
static void
|
|
|
|
rsu_tx_task(void *arg, int pending __unused)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = arg;
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
_rsu_start(sc);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
2015-09-22 05:48:51 +00:00
|
|
|
#define RSU_PWR_UNKNOWN 0x0
|
2015-09-22 02:57:18 +00:00
|
|
|
#define RSU_PWR_ACTIVE 0x1
|
|
|
|
#define RSU_PWR_OFF 0x2
|
|
|
|
#define RSU_PWR_SLEEP 0x3
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the current power state.
|
|
|
|
*
|
|
|
|
* The rtlwifi code doesn't do this so aggressively; it
|
|
|
|
* waits for an idle period after association with
|
|
|
|
* no traffic before doing this.
|
|
|
|
*
|
|
|
|
* For now - it's on in all states except RUN, and
|
|
|
|
* in RUN it'll transition to allow sleep.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct r92s_pwr_cmd {
|
|
|
|
uint8_t mode;
|
|
|
|
uint8_t smart_ps;
|
|
|
|
uint8_t bcn_pass_time;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_set_fw_power_state(struct rsu_softc *sc, int state)
|
|
|
|
{
|
|
|
|
struct r92s_set_pwr_mode cmd;
|
|
|
|
//struct r92s_pwr_cmd cmd;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
2015-09-22 05:48:51 +00:00
|
|
|
/* only change state if required */
|
|
|
|
if (sc->sc_curpwrstate == state)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
|
|
|
|
2015-09-22 02:57:18 +00:00
|
|
|
switch (state) {
|
|
|
|
case RSU_PWR_ACTIVE:
|
|
|
|
/* Force the hardware awake */
|
|
|
|
rsu_write_1(sc, R92S_USB_HRPWM,
|
|
|
|
R92S_USB_HRPWM_PS_ST_ACTIVE | R92S_USB_HRPWM_PS_ALL_ON);
|
|
|
|
cmd.mode = R92S_PS_MODE_ACTIVE;
|
|
|
|
break;
|
|
|
|
case RSU_PWR_SLEEP:
|
|
|
|
cmd.mode = R92S_PS_MODE_DTIM; /* XXX configurable? */
|
|
|
|
cmd.smart_ps = 1; /* XXX 2 if doing p2p */
|
|
|
|
cmd.bcn_pass_time = 5; /* in 100mS usb.c, linux/rtlwifi */
|
|
|
|
break;
|
2015-09-22 05:48:51 +00:00
|
|
|
case RSU_PWR_OFF:
|
|
|
|
cmd.mode = R92S_PS_MODE_RADIOOFF;
|
|
|
|
break;
|
2015-09-22 02:57:18 +00:00
|
|
|
default:
|
|
|
|
device_printf(sc->sc_dev, "%s: unknown ps mode (%d)\n",
|
|
|
|
__func__,
|
|
|
|
state);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RESET,
|
|
|
|
"%s: setting ps mode to %d (mode %d)\n",
|
|
|
|
__func__, state, cmd.mode);
|
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_PWR_MODE, &cmd, sizeof(cmd));
|
2015-09-22 05:48:51 +00:00
|
|
|
if (error == 0)
|
|
|
|
sc->sc_curpwrstate = state;
|
2015-09-22 02:57:18 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2016-12-10 18:47:13 +00:00
|
|
|
static void
|
|
|
|
rsu_set_led(struct rsu_softc *sc, int on)
|
|
|
|
{
|
|
|
|
rsu_write_1(sc, R92S_LEDCFG,
|
|
|
|
(rsu_read_1(sc, R92S_LEDCFG) & 0xf0) | (!on << 3));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_monitor_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate,
|
|
|
|
int arg)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = vap->iv_ic;
|
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
|
|
|
struct rsu_vap *uvp = RSU_VAP(vap);
|
|
|
|
|
|
|
|
if (vap->iv_state != nstate) {
|
|
|
|
IEEE80211_UNLOCK(ic);
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
|
|
|
|
switch (nstate) {
|
|
|
|
case IEEE80211_S_INIT:
|
|
|
|
sc->sc_vap_is_running = 0;
|
|
|
|
rsu_set_led(sc, 0);
|
|
|
|
break;
|
|
|
|
case IEEE80211_S_RUN:
|
|
|
|
sc->sc_vap_is_running = 1;
|
|
|
|
rsu_set_led(sc, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* NOTREACHED */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rsu_rxfilter_refresh(sc);
|
|
|
|
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
IEEE80211_LOCK(ic);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (uvp->newstate(vap, nstate, arg));
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static int
|
|
|
|
rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
|
|
|
|
{
|
|
|
|
struct rsu_vap *uvp = RSU_VAP(vap);
|
|
|
|
struct ieee80211com *ic = vap->iv_ic;
|
2015-08-20 05:13:54 +00:00
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct ieee80211_node *ni;
|
|
|
|
struct ieee80211_rateset *rs;
|
|
|
|
enum ieee80211_state ostate;
|
|
|
|
int error, startcal = 0;
|
|
|
|
|
|
|
|
ostate = vap->iv_state;
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_STATE, "%s: %s -> %s\n",
|
|
|
|
__func__,
|
|
|
|
ieee80211_state_name[ostate],
|
2013-07-30 02:07:57 +00:00
|
|
|
ieee80211_state_name[nstate]);
|
|
|
|
|
|
|
|
IEEE80211_UNLOCK(ic);
|
|
|
|
if (ostate == IEEE80211_S_RUN) {
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
/* Stop calibration. */
|
|
|
|
sc->sc_calibrating = 0;
|
2016-12-06 00:13:49 +00:00
|
|
|
|
|
|
|
/* Pause Tx for AC queues. */
|
|
|
|
rsu_write_1(sc, R92S_TXPAUSE, R92S_TXPAUSE_AC);
|
|
|
|
usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10));
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task);
|
2015-09-21 02:30:22 +00:00
|
|
|
taskqueue_drain(taskqueue_thread, &sc->tx_task);
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_LOCK(sc);
|
2016-12-06 00:13:49 +00:00
|
|
|
/* Disassociate from our current BSS. */
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_disconnect(sc);
|
2016-12-10 18:47:13 +00:00
|
|
|
usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10));
|
|
|
|
|
|
|
|
/* Refresh Rx filter (may be modified by firmware). */
|
|
|
|
sc->sc_vap_is_running = 0;
|
|
|
|
rsu_rxfilter_refresh(sc);
|
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
/* Reinstall static keys. */
|
|
|
|
if (sc->sc_running)
|
|
|
|
rsu_reinit_static_keys(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
} else
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
switch (nstate) {
|
|
|
|
case IEEE80211_S_INIT:
|
2015-09-22 02:57:18 +00:00
|
|
|
(void) rsu_set_fw_power_state(sc, RSU_PWR_ACTIVE);
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
|
|
|
case IEEE80211_S_AUTH:
|
|
|
|
ni = ieee80211_ref_node(vap->iv_bss);
|
2015-09-22 02:57:18 +00:00
|
|
|
(void) rsu_set_fw_power_state(sc, RSU_PWR_ACTIVE);
|
2013-07-30 02:07:57 +00:00
|
|
|
error = rsu_join_bss(sc, ni);
|
|
|
|
ieee80211_free_node(ni);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not send join command\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IEEE80211_S_RUN:
|
2016-12-06 00:13:49 +00:00
|
|
|
/* Flush all AC queues. */
|
|
|
|
rsu_write_1(sc, R92S_TXPAUSE, 0);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
ni = ieee80211_ref_node(vap->iv_bss);
|
|
|
|
rs = &ni->ni_rates;
|
|
|
|
/* Indicate highest supported rate. */
|
|
|
|
ni->ni_txrate = rs->rs_rates[rs->rs_nrates - 1];
|
2015-09-22 02:57:18 +00:00
|
|
|
(void) rsu_set_fw_power_state(sc, RSU_PWR_SLEEP);
|
2013-07-30 02:07:57 +00:00
|
|
|
ieee80211_free_node(ni);
|
|
|
|
startcal = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-09-25 19:13:07 +00:00
|
|
|
if (startcal != 0) {
|
|
|
|
sc->sc_calibrating = 1;
|
|
|
|
/* Start periodic calibration. */
|
|
|
|
taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task,
|
|
|
|
hz);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
IEEE80211_LOCK(ic);
|
|
|
|
return (uvp->newstate(vap, nstate, arg));
|
|
|
|
}
|
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
static int
|
|
|
|
rsu_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k,
|
|
|
|
ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = vap->iv_ic->ic_softc;
|
|
|
|
int is_checked = 0;
|
|
|
|
|
|
|
|
if (&vap->iv_nw_keys[0] <= k &&
|
|
|
|
k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
|
2016-12-07 22:16:07 +00:00
|
|
|
*keyix = ieee80211_crypto_get_key_wepidx(vap, k);
|
2016-12-06 00:13:49 +00:00
|
|
|
} else {
|
|
|
|
if (vap->iv_opmode != IEEE80211_M_STA) {
|
|
|
|
*keyix = 0;
|
|
|
|
/* TODO: obtain keyix from node id */
|
|
|
|
is_checked = 1;
|
|
|
|
k->wk_flags |= IEEE80211_KEY_SWCRYPT;
|
|
|
|
} else
|
|
|
|
*keyix = R92S_MACID_BSS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_checked) {
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
if (isset(sc->keys_bmap, *keyix)) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: key slot %d is already used!\n",
|
|
|
|
__func__, *keyix);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
setbit(sc->keys_bmap, *keyix);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
*rxkeyix = *keyix;
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_process_key(struct ieee80211vap *vap, const struct ieee80211_key *k,
|
|
|
|
int set)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = vap->iv_ic->ic_softc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (k->wk_flags & IEEE80211_KEY_SWCRYPT) {
|
|
|
|
/* Not for us. */
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle group keys. */
|
|
|
|
if (&vap->iv_nw_keys[0] <= k &&
|
|
|
|
k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
|
|
|
|
KASSERT(k->wk_keyix < nitems(sc->group_keys),
|
2016-12-06 06:12:01 +00:00
|
|
|
("keyix %u > %zu\n", k->wk_keyix, nitems(sc->group_keys)));
|
2016-12-06 00:13:49 +00:00
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
sc->group_keys[k->wk_keyix] = (set ? k : NULL);
|
|
|
|
if (!sc->sc_running) {
|
|
|
|
/* Static keys will be set during device startup. */
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set)
|
|
|
|
ret = rsu_set_key_group(sc, k);
|
|
|
|
else
|
|
|
|
ret = rsu_delete_key(sc, k->wk_keyix);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
|
|
|
return (!ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set) {
|
|
|
|
/* wait for pending key removal */
|
|
|
|
taskqueue_drain(taskqueue_thread, &sc->del_key_task);
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
ret = rsu_set_key_pair(sc, k);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
} else {
|
|
|
|
RSU_DELKEY_BMAP_LOCK(sc);
|
|
|
|
setbit(sc->free_keys_bmap, k->wk_keyix);
|
|
|
|
RSU_DELKEY_BMAP_UNLOCK(sc);
|
|
|
|
|
|
|
|
/* workaround ieee80211_node_delucastkey() locking */
|
|
|
|
taskqueue_enqueue(taskqueue_thread, &sc->del_key_task);
|
|
|
|
ret = 0; /* fake success */
|
|
|
|
}
|
|
|
|
|
|
|
|
return (!ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
|
|
|
|
{
|
|
|
|
return (rsu_process_key(vap, k, 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
|
|
|
|
{
|
|
|
|
return (rsu_process_key(vap, k, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_cam_read(struct rsu_softc *sc, uint8_t addr, uint32_t *val)
|
|
|
|
{
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
rsu_write_4(sc, R92S_CAMCMD,
|
|
|
|
R92S_CAMCMD_POLLING | SM(R92S_CAMCMD_ADDR, addr));
|
|
|
|
for (ntries = 0; ntries < 10; ntries++) {
|
|
|
|
if (!(rsu_read_4(sc, R92S_CAMCMD) & R92S_CAMCMD_POLLING))
|
|
|
|
break;
|
|
|
|
|
|
|
|
usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(1));
|
|
|
|
}
|
|
|
|
if (ntries == 10) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: cannot read CAM entry at address %02X\n",
|
|
|
|
__func__, addr);
|
|
|
|
return (ETIMEDOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
*val = rsu_read_4(sc, R92S_CAMREAD);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static void
|
2016-12-06 00:13:49 +00:00
|
|
|
rsu_cam_write(struct rsu_softc *sc, uint8_t addr, uint32_t data)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
rsu_write_4(sc, R92S_CAMWRITE, data);
|
|
|
|
rsu_write_4(sc, R92S_CAMCMD,
|
|
|
|
R92S_CAMCMD_POLLING | R92S_CAMCMD_WRITE |
|
|
|
|
SM(R92S_CAMCMD_ADDR, addr));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_key_check(struct rsu_softc *sc, ieee80211_keyix keyix, int is_valid)
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
int error, ntries;
|
|
|
|
|
|
|
|
for (ntries = 0; ntries < 20; ntries++) {
|
|
|
|
usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(1));
|
|
|
|
|
|
|
|
error = rsu_cam_read(sc, R92S_CAM_CTL0(keyix), &val);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: cannot check key status!\n", __func__);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (((val & R92S_CAM_VALID) == 0) ^ is_valid)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ntries == 20) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: key %d is %s marked as valid, rejecting request\n",
|
|
|
|
__func__, keyix, is_valid ? "not" : "still");
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Map net80211 cipher to RTL8712 security mode.
|
|
|
|
*/
|
|
|
|
static uint8_t
|
|
|
|
rsu_crypto_mode(struct rsu_softc *sc, u_int cipher, int keylen)
|
|
|
|
{
|
|
|
|
switch (cipher) {
|
2013-07-30 02:07:57 +00:00
|
|
|
case IEEE80211_CIPHER_WEP:
|
2016-12-06 00:13:49 +00:00
|
|
|
return keylen < 8 ? R92S_KEY_ALGO_WEP40 : R92S_KEY_ALGO_WEP104;
|
2013-07-30 02:07:57 +00:00
|
|
|
case IEEE80211_CIPHER_TKIP:
|
2016-12-06 00:13:49 +00:00
|
|
|
return R92S_KEY_ALGO_TKIP;
|
2013-07-30 02:07:57 +00:00
|
|
|
case IEEE80211_CIPHER_AES_CCM:
|
2016-12-06 00:13:49 +00:00
|
|
|
return R92S_KEY_ALGO_AES;
|
2013-07-30 02:07:57 +00:00
|
|
|
default:
|
2016-12-06 00:13:49 +00:00
|
|
|
device_printf(sc->sc_dev, "unknown cipher %d\n", cipher);
|
|
|
|
return R92S_KEY_ALGO_INVALID;
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
2016-12-06 00:13:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_set_key_group(struct rsu_softc *sc, const struct ieee80211_key *k)
|
|
|
|
{
|
|
|
|
struct r92s_fw_cmd_set_key key;
|
|
|
|
uint8_t algo;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
/* Map net80211 cipher to HW crypto algorithm. */
|
|
|
|
algo = rsu_crypto_mode(sc, k->wk_cipher->ic_cipher, k->wk_keylen);
|
|
|
|
if (algo == R92S_KEY_ALGO_INVALID)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
memset(&key, 0, sizeof(key));
|
|
|
|
key.algo = algo;
|
|
|
|
key.cam_id = k->wk_keyix;
|
2013-07-30 02:07:57 +00:00
|
|
|
key.grpkey = (k->wk_flags & IEEE80211_KEY_GROUP) != 0;
|
|
|
|
memcpy(key.key, k->wk_key, MIN(k->wk_keylen, sizeof(key.key)));
|
2016-12-06 00:13:49 +00:00
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_KEY | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: keyix %u, group %u, algo %u/%u, flags %04X, len %u, "
|
|
|
|
"macaddr %s\n", __func__, key.cam_id, key.grpkey,
|
|
|
|
k->wk_cipher->ic_cipher, key.algo, k->wk_flags, k->wk_keylen,
|
|
|
|
ether_sprintf(k->wk_macaddr));
|
|
|
|
|
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_KEY, &key, sizeof(key));
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: cannot send firmware command, error %d\n",
|
|
|
|
__func__, error);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (rsu_key_check(sc, k->wk_keyix, 1));
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
static int
|
|
|
|
rsu_set_key_pair(struct rsu_softc *sc, const struct ieee80211_key *k)
|
|
|
|
{
|
|
|
|
struct r92s_fw_cmd_set_key_mac key;
|
|
|
|
uint8_t algo;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
if (!sc->sc_running)
|
|
|
|
return (ESHUTDOWN);
|
|
|
|
|
|
|
|
/* Map net80211 cipher to HW crypto algorithm. */
|
|
|
|
algo = rsu_crypto_mode(sc, k->wk_cipher->ic_cipher, k->wk_keylen);
|
|
|
|
if (algo == R92S_KEY_ALGO_INVALID)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
memset(&key, 0, sizeof(key));
|
|
|
|
key.algo = algo;
|
|
|
|
memcpy(key.macaddr, k->wk_macaddr, sizeof(key.macaddr));
|
|
|
|
memcpy(key.key, k->wk_key, MIN(k->wk_keylen, sizeof(key.key)));
|
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_KEY | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: keyix %u, algo %u/%u, flags %04X, len %u, macaddr %s\n",
|
|
|
|
__func__, k->wk_keyix, k->wk_cipher->ic_cipher, key.algo,
|
|
|
|
k->wk_flags, k->wk_keylen, ether_sprintf(key.macaddr));
|
|
|
|
|
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_STA_KEY, &key, sizeof(key));
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: cannot send firmware command, error %d\n",
|
|
|
|
__func__, error);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (rsu_key_check(sc, k->wk_keyix, 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_reinit_static_keys(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
int i, error;
|
|
|
|
|
|
|
|
for (i = 0; i < nitems(sc->group_keys); i++) {
|
|
|
|
if (sc->group_keys[i] != NULL) {
|
|
|
|
error = rsu_set_key_group(sc, sc->group_keys[i]);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: failed to set static key %d, "
|
|
|
|
"error %d\n", __func__, i, error);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_delete_key(struct rsu_softc *sc, ieee80211_keyix keyix)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
struct r92s_fw_cmd_set_key key;
|
2016-12-06 00:13:49 +00:00
|
|
|
uint32_t val;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
if (!sc->sc_running)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
/* check if it was automatically removed by firmware */
|
|
|
|
error = rsu_cam_read(sc, R92S_CAM_CTL0(keyix), &val);
|
|
|
|
if (error == 0 && (val & R92S_CAM_VALID) == 0) {
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_KEY,
|
|
|
|
"%s: key %u does not exist\n", __func__, keyix);
|
|
|
|
clrbit(sc->keys_bmap, keyix);
|
|
|
|
return (0);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
memset(&key, 0, sizeof(key));
|
2016-12-06 00:13:49 +00:00
|
|
|
key.cam_id = keyix;
|
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_KEY | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: removing key %u\n", __func__, key.cam_id);
|
|
|
|
|
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_KEY, &key, sizeof(key));
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: cannot send firmware command, error %d\n",
|
|
|
|
__func__, error);
|
|
|
|
goto finish;
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(5));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear 'valid' bit manually (cannot be done via firmware command).
|
|
|
|
* Used for key check + when firmware command cannot be sent.
|
|
|
|
*/
|
|
|
|
finish:
|
|
|
|
rsu_cam_write(sc, R92S_CAM_CTL0(keyix), 0);
|
|
|
|
|
|
|
|
clrbit(sc->keys_bmap, keyix);
|
|
|
|
|
|
|
|
return (rsu_key_check(sc, keyix, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_delete_key_pair_cb(void *arg, int pending __unused)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = arg;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
RSU_DELKEY_BMAP_LOCK(sc);
|
|
|
|
for (i = IEEE80211_WEP_NKID; i < R92S_CAM_ENTRY_LIMIT; i++) {
|
|
|
|
if (isset(sc->free_keys_bmap, i)) {
|
|
|
|
RSU_DELKEY_BMAP_UNLOCK(sc);
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_KEY,
|
|
|
|
"%s: calling rsu_delete_key() with keyix = %d\n",
|
|
|
|
__func__, i);
|
|
|
|
(void) rsu_delete_key(sc, i);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
|
|
|
RSU_DELKEY_BMAP_LOCK(sc);
|
|
|
|
clrbit(sc->free_keys_bmap, i);
|
|
|
|
|
|
|
|
/* bmap can be changed */
|
|
|
|
i = IEEE80211_WEP_NKID - 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RSU_DELKEY_BMAP_UNLOCK(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-11-27 12:03:34 +00:00
|
|
|
rsu_site_survey(struct rsu_softc *sc, struct ieee80211_scan_ssid *ssid)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
struct r92s_fw_cmd_sitesurvey cmd;
|
2015-09-18 07:55:33 +00:00
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
memset(&cmd, 0, sizeof(cmd));
|
2016-11-27 12:03:34 +00:00
|
|
|
/* TODO: passive channels? */
|
|
|
|
if (sc->sc_active_scan)
|
2013-07-30 02:07:57 +00:00
|
|
|
cmd.active = htole32(1);
|
|
|
|
cmd.limit = htole32(48);
|
2016-11-27 12:03:34 +00:00
|
|
|
|
|
|
|
if (ssid != NULL) {
|
|
|
|
sc->sc_extra_scan = 1;
|
|
|
|
cmd.ssidlen = htole32(ssid->len);
|
|
|
|
memcpy(cmd.ssid, ssid->ssid, ssid->len);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
2016-11-27 12:03:34 +00:00
|
|
|
#ifdef USB_DEBUG
|
|
|
|
if (rsu_debug & (RSU_DEBUG_SCAN | RSU_DEBUG_FWCMD)) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"sending site survey command, active %d",
|
|
|
|
le32toh(cmd.active));
|
|
|
|
if (ssid != NULL) {
|
|
|
|
printf(", ssid: ");
|
|
|
|
ieee80211_print_essid(cmd.ssid, le32toh(cmd.ssidlen));
|
|
|
|
}
|
|
|
|
printf("\n");
|
2015-09-18 07:55:33 +00:00
|
|
|
}
|
2016-11-27 12:03:34 +00:00
|
|
|
#endif
|
|
|
|
return (rsu_fw_cmd(sc, R92S_CMD_SITE_SURVEY, &cmd, sizeof(cmd)));
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_join_bss(struct rsu_softc *sc, 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 ieee80211com *ic = &sc->sc_ic;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ndis_wlan_bssid_ex *bss;
|
|
|
|
struct ndis_802_11_fixed_ies *fixed;
|
|
|
|
struct r92s_fw_cmd_auth auth;
|
2014-06-04 16:58:35 +00:00
|
|
|
uint8_t buf[sizeof(*bss) + 128] __aligned(4);
|
|
|
|
uint8_t *frm;
|
2013-07-30 02:07:57 +00:00
|
|
|
uint8_t opmode;
|
|
|
|
int error;
|
2015-09-18 07:55:33 +00:00
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Let the FW decide the opmode based on the capinfo field. */
|
|
|
|
opmode = NDIS802_11AUTOUNKNOWN;
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RESET,
|
|
|
|
"%s: setting operating mode to %d\n",
|
|
|
|
__func__, opmode);
|
2013-07-30 02:07:57 +00:00
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_OPMODE, &opmode, sizeof(opmode));
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
memset(&auth, 0, sizeof(auth));
|
|
|
|
if (vap->iv_flags & IEEE80211_F_WPA) {
|
|
|
|
auth.mode = R92S_AUTHMODE_WPA;
|
2014-06-04 16:58:35 +00:00
|
|
|
auth.dot1x = (ni->ni_authmode == IEEE80211_AUTH_8021X);
|
2013-07-30 02:07:57 +00:00
|
|
|
} else
|
|
|
|
auth.mode = R92S_AUTHMODE_OPEN;
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RESET,
|
|
|
|
"%s: setting auth mode to %d\n",
|
|
|
|
__func__, auth.mode);
|
2013-07-30 02:07:57 +00:00
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_AUTH, &auth, sizeof(auth));
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
bss = (struct ndis_wlan_bssid_ex *)buf;
|
|
|
|
IEEE80211_ADDR_COPY(bss->macaddr, ni->ni_bssid);
|
|
|
|
bss->ssid.ssidlen = htole32(ni->ni_esslen);
|
|
|
|
memcpy(bss->ssid.ssid, ni->ni_essid, ni->ni_esslen);
|
|
|
|
if (vap->iv_flags & (IEEE80211_F_PRIVACY | IEEE80211_F_WPA))
|
|
|
|
bss->privacy = htole32(1);
|
|
|
|
bss->rssi = htole32(ni->ni_avgrssi);
|
|
|
|
if (ic->ic_curmode == IEEE80211_MODE_11B)
|
|
|
|
bss->networktype = htole32(NDIS802_11DS);
|
|
|
|
else
|
|
|
|
bss->networktype = htole32(NDIS802_11OFDM24);
|
|
|
|
bss->config.len = htole32(sizeof(bss->config));
|
|
|
|
bss->config.bintval = htole32(ni->ni_intval);
|
|
|
|
bss->config.dsconfig = htole32(ieee80211_chan2ieee(ic, ni->ni_chan));
|
|
|
|
bss->inframode = htole32(NDIS802_11INFRASTRUCTURE);
|
2015-09-12 23:10:34 +00:00
|
|
|
/* XXX verify how this is supposed to look! */
|
2013-07-30 02:07:57 +00:00
|
|
|
memcpy(bss->supprates, ni->ni_rates.rs_rates,
|
|
|
|
ni->ni_rates.rs_nrates);
|
|
|
|
/* Write the fixed fields of the beacon frame. */
|
|
|
|
fixed = (struct ndis_802_11_fixed_ies *)&bss[1];
|
|
|
|
memcpy(&fixed->tstamp, ni->ni_tstamp.data, 8);
|
|
|
|
fixed->bintval = htole16(ni->ni_intval);
|
|
|
|
fixed->capabilities = htole16(ni->ni_capinfo);
|
|
|
|
/* Write IEs to be included in the association request. */
|
|
|
|
frm = (uint8_t *)&fixed[1];
|
|
|
|
frm = ieee80211_add_rsn(frm, vap);
|
|
|
|
frm = ieee80211_add_wpa(frm, vap);
|
|
|
|
frm = ieee80211_add_qos(frm, ni);
|
2015-09-18 04:12:11 +00:00
|
|
|
if ((ic->ic_flags & IEEE80211_F_WME) &&
|
|
|
|
(ni->ni_ies.wme_ie != NULL))
|
|
|
|
frm = ieee80211_add_wme_info(frm, &ic->ic_wme);
|
2015-09-26 07:25:53 +00:00
|
|
|
if (ni->ni_flags & IEEE80211_NODE_HT) {
|
2013-07-30 02:07:57 +00:00
|
|
|
frm = ieee80211_add_htcap(frm, ni);
|
2015-09-26 07:25:53 +00:00
|
|
|
frm = ieee80211_add_htinfo(frm, ni);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
bss->ieslen = htole32(frm - (uint8_t *)fixed);
|
|
|
|
bss->len = htole32(((frm - buf) + 3) & ~3);
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RESET | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: sending join bss command to %s chan %d\n",
|
|
|
|
__func__,
|
2013-07-30 02:07:57 +00:00
|
|
|
ether_sprintf(bss->macaddr), le32toh(bss->config.dsconfig));
|
|
|
|
return (rsu_fw_cmd(sc, R92S_CMD_JOIN_BSS, buf, sizeof(buf)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_disconnect(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
uint32_t zero = 0; /* :-) */
|
|
|
|
|
|
|
|
/* Disassociate from our current BSS. */
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_STATE | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: sending disconnect command\n", __func__);
|
2013-07-30 02:07:57 +00:00
|
|
|
return (rsu_fw_cmd(sc, R92S_CMD_DISCONNECT, &zero, sizeof(zero)));
|
|
|
|
}
|
|
|
|
|
2015-09-30 05:19:16 +00:00
|
|
|
/*
|
|
|
|
* Map the hardware provided RSSI value to a signal level.
|
|
|
|
* For the most part it's just something we divide by and cap
|
|
|
|
* so it doesn't overflow the representation by net80211.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
rsu_hwrssi_to_rssi(struct rsu_softc *sc, int hw_rssi)
|
|
|
|
{
|
|
|
|
int v;
|
|
|
|
|
|
|
|
if (hw_rssi == 0)
|
|
|
|
return (0);
|
|
|
|
v = hw_rssi >> 4;
|
|
|
|
if (v > 80)
|
|
|
|
v = 80;
|
|
|
|
return (v);
|
|
|
|
}
|
|
|
|
|
2017-07-30 16:45:28 +00:00
|
|
|
CTASSERT(MCLBYTES > sizeof(struct ieee80211_frame));
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static void
|
|
|
|
rsu_event_survey(struct rsu_softc *sc, uint8_t *buf, int len)
|
|
|
|
{
|
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;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct ieee80211_frame *wh;
|
|
|
|
struct ndis_wlan_bssid_ex *bss;
|
2015-09-15 03:01:40 +00:00
|
|
|
struct ieee80211_rx_stats rxs;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct mbuf *m;
|
2017-07-30 16:45:28 +00:00
|
|
|
uint32_t ieslen;
|
|
|
|
uint32_t pktlen;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
if (__predict_false(len < sizeof(*bss)))
|
|
|
|
return;
|
|
|
|
bss = (struct ndis_wlan_bssid_ex *)buf;
|
2017-07-30 16:45:28 +00:00
|
|
|
ieslen = le32toh(bss->ieslen);
|
|
|
|
/* range check length of information element */
|
|
|
|
if (__predict_false(ieslen > (uint32_t)(len - sizeof(*bss))))
|
2013-07-30 02:07:57 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_SCAN,
|
|
|
|
"%s: found BSS %s: len=%d chan=%d inframode=%d "
|
2015-09-13 05:22:20 +00:00
|
|
|
"networktype=%d privacy=%d, RSSI=%d\n",
|
2015-09-12 23:10:34 +00:00
|
|
|
__func__,
|
2017-07-30 16:45:28 +00:00
|
|
|
ether_sprintf(bss->macaddr), ieslen,
|
2013-07-30 02:07:57 +00:00
|
|
|
le32toh(bss->config.dsconfig), le32toh(bss->inframode),
|
2015-09-13 05:22:20 +00:00
|
|
|
le32toh(bss->networktype), le32toh(bss->privacy),
|
|
|
|
le32toh(bss->rssi));
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Build a fake beacon frame to let net80211 do all the parsing. */
|
2015-09-12 23:10:34 +00:00
|
|
|
/* XXX TODO: just call the new scan API methods! */
|
2017-07-30 16:45:28 +00:00
|
|
|
if (__predict_false(ieslen > (size_t)(MCLBYTES - sizeof(*wh))))
|
2013-07-30 02:07:57 +00:00
|
|
|
return;
|
2017-07-30 16:45:28 +00:00
|
|
|
pktlen = sizeof(*wh) + ieslen;
|
2014-01-10 14:47:20 +00:00
|
|
|
m = m_get2(pktlen, M_NOWAIT, MT_DATA, M_PKTHDR);
|
2013-07-30 02:07:57 +00:00
|
|
|
if (__predict_false(m == NULL))
|
|
|
|
return;
|
|
|
|
wh = mtod(m, struct ieee80211_frame *);
|
|
|
|
wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
|
|
|
|
IEEE80211_FC0_SUBTYPE_BEACON;
|
|
|
|
wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
|
2013-12-04 12:07:46 +00:00
|
|
|
USETW(wh->i_dur, 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
|
|
|
IEEE80211_ADDR_COPY(wh->i_addr1, ieee80211broadcastaddr);
|
2013-07-30 02:07:57 +00:00
|
|
|
IEEE80211_ADDR_COPY(wh->i_addr2, bss->macaddr);
|
|
|
|
IEEE80211_ADDR_COPY(wh->i_addr3, bss->macaddr);
|
|
|
|
*(uint16_t *)wh->i_seq = 0;
|
2017-07-30 16:45:28 +00:00
|
|
|
memcpy(&wh[1], (uint8_t *)&bss[1], ieslen);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Finalize mbuf. */
|
|
|
|
m->m_pkthdr.len = m->m_len = pktlen;
|
2015-09-15 03:01:40 +00:00
|
|
|
|
|
|
|
/* Set channel flags for input path */
|
|
|
|
bzero(&rxs, sizeof(rxs));
|
|
|
|
rxs.r_flags |= IEEE80211_R_IEEE | IEEE80211_R_FREQ;
|
|
|
|
rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI;
|
|
|
|
rxs.c_ieee = le32toh(bss->config.dsconfig);
|
|
|
|
rxs.c_freq = ieee80211_ieee2mhz(rxs.c_ieee, IEEE80211_CHAN_2GHZ);
|
2015-09-30 05:19:16 +00:00
|
|
|
/* This is a number from 0..100; so let's just divide it down a bit */
|
2016-10-08 01:12:29 +00:00
|
|
|
rxs.c_rssi = le32toh(bss->rssi) / 2;
|
|
|
|
rxs.c_nf = -96;
|
2016-10-12 20:50:13 +00:00
|
|
|
if (ieee80211_add_rx_params(m, &rxs) == 0)
|
|
|
|
return;
|
2015-09-15 03:01:40 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* XXX avoid a LOR */
|
|
|
|
RSU_UNLOCK(sc);
|
2016-10-12 20:50:13 +00:00
|
|
|
ieee80211_input_mimo_all(ic, m);
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_LOCK(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_event_join_bss(struct rsu_softc *sc, uint8_t *buf, int len)
|
|
|
|
{
|
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;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
|
|
|
struct ieee80211_node *ni = vap->iv_bss;
|
|
|
|
struct r92s_event_join_bss *rsp;
|
2014-06-04 16:58:35 +00:00
|
|
|
uint32_t tmp;
|
2013-07-30 02:07:57 +00:00
|
|
|
int res;
|
|
|
|
|
|
|
|
if (__predict_false(len < sizeof(*rsp)))
|
|
|
|
return;
|
|
|
|
rsp = (struct r92s_event_join_bss *)buf;
|
|
|
|
res = (int)le32toh(rsp->join_res);
|
|
|
|
|
2015-09-13 04:12:51 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_STATE | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: Rx join BSS event len=%d res=%d\n",
|
|
|
|
__func__, len, res);
|
2015-09-18 07:55:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Don't do this; there's likely a better way to tell
|
|
|
|
* the caller we failed.
|
|
|
|
*/
|
2013-07-30 02:07:57 +00:00
|
|
|
if (res <= 0) {
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
return;
|
|
|
|
}
|
2015-09-18 07:55:33 +00:00
|
|
|
|
2014-06-04 16:58:35 +00:00
|
|
|
tmp = le32toh(rsp->associd);
|
|
|
|
if (tmp >= vap->iv_max_aid) {
|
2016-12-10 20:19:57 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_ANY, "Assoc ID overflow\n");
|
2014-06-04 16:58:35 +00:00
|
|
|
tmp = 1;
|
|
|
|
}
|
2015-09-13 04:12:51 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_STATE | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: associated with %s associd=%d\n",
|
|
|
|
__func__, ether_sprintf(rsp->bss.macaddr), tmp);
|
|
|
|
/* XXX is this required? What's the top two bits for again? */
|
2014-06-04 16:58:35 +00:00
|
|
|
ni->ni_associd = tmp | 0xc000;
|
2016-12-10 18:47:13 +00:00
|
|
|
|
|
|
|
/* Refresh Rx filter (was changed by firmware). */
|
|
|
|
sc->sc_vap_is_running = 1;
|
|
|
|
rsu_rxfilter_refresh(sc);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
ieee80211_new_state(vap, IEEE80211_S_RUN,
|
|
|
|
IEEE80211_FC0_SUBTYPE_ASSOC_RESP);
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
}
|
|
|
|
|
2015-09-18 05:03:01 +00:00
|
|
|
static void
|
|
|
|
rsu_event_addba_req_report(struct rsu_softc *sc, uint8_t *buf, int len)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
|
|
|
struct r92s_add_ba_event *ba = (void *) buf;
|
|
|
|
struct ieee80211_node *ni;
|
|
|
|
|
|
|
|
if (len < sizeof(*ba)) {
|
|
|
|
device_printf(sc->sc_dev, "%s: short read (%d)\n", __func__, len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vap == NULL)
|
|
|
|
return;
|
|
|
|
|
2015-09-30 05:19:16 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_AMPDU, "%s: mac=%s, tid=%d, ssn=%d\n",
|
2015-09-18 05:03:01 +00:00
|
|
|
__func__,
|
|
|
|
ether_sprintf(ba->mac_addr),
|
|
|
|
(int) ba->tid,
|
|
|
|
(int) le16toh(ba->ssn));
|
|
|
|
|
|
|
|
/* XXX do node lookup; this is STA specific */
|
|
|
|
|
|
|
|
ni = ieee80211_ref_node(vap->iv_bss);
|
|
|
|
ieee80211_ampdu_rx_start_ext(ni, ba->tid, le16toh(ba->ssn) >> 4, 32);
|
|
|
|
ieee80211_free_node(ni);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static void
|
|
|
|
rsu_rx_event(struct rsu_softc *sc, uint8_t code, uint8_t *buf, int len)
|
|
|
|
{
|
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;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
|
|
|
|
2015-09-13 04:12:51 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX | RSU_DEBUG_FWCMD,
|
2015-09-12 23:10:34 +00:00
|
|
|
"%s: Rx event code=%d len=%d\n", __func__, code, len);
|
2013-07-30 02:07:57 +00:00
|
|
|
switch (code) {
|
|
|
|
case R92S_EVT_SURVEY:
|
2015-09-18 04:12:11 +00:00
|
|
|
rsu_event_survey(sc, buf, len);
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
|
|
|
case R92S_EVT_SURVEY_DONE:
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_SCAN,
|
2016-11-27 12:03:34 +00:00
|
|
|
"%s: %s scan done, found %d BSS\n",
|
|
|
|
__func__, sc->sc_extra_scan ? "direct" : "broadcast",
|
|
|
|
le32toh(*(uint32_t *)buf));
|
|
|
|
if (sc->sc_extra_scan == 1) {
|
|
|
|
/* Send broadcast probe request. */
|
|
|
|
sc->sc_extra_scan = 0;
|
|
|
|
if (vap != NULL && rsu_site_survey(sc, NULL) != 0) {
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
ieee80211_cancel_scan(vap);
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (vap != NULL) {
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(sc);
|
2016-11-27 12:03:34 +00:00
|
|
|
ieee80211_scan_done(vap);
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_LOCK(sc);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case R92S_EVT_JOIN_BSS:
|
|
|
|
if (vap->iv_state == IEEE80211_S_AUTH)
|
|
|
|
rsu_event_join_bss(sc, buf, len);
|
|
|
|
break;
|
|
|
|
case R92S_EVT_DEL_STA:
|
2015-09-13 04:12:51 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_FWCMD | RSU_DEBUG_STATE,
|
|
|
|
"%s: disassociated from %s\n", __func__,
|
|
|
|
ether_sprintf(buf));
|
2013-07-30 02:07:57 +00:00
|
|
|
if (vap->iv_state == IEEE80211_S_RUN &&
|
|
|
|
IEEE80211_ADDR_EQ(vap->iv_bss->ni_bssid, buf)) {
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case R92S_EVT_WPS_PBC:
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX | RSU_DEBUG_FWCMD,
|
|
|
|
"%s: WPS PBC pushed.\n", __func__);
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
|
|
|
case R92S_EVT_FWDBG:
|
2015-09-12 23:10:34 +00:00
|
|
|
buf[60] = '\0';
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_FWDBG, "FWDBG: %s\n", (char *)buf);
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
2015-09-18 05:03:01 +00:00
|
|
|
case R92S_EVT_ADDBA_REQ_REPORT:
|
|
|
|
rsu_event_addba_req_report(sc, buf, len);
|
|
|
|
break;
|
2014-06-04 09:18:13 +00:00
|
|
|
default:
|
2015-09-22 02:57:18 +00:00
|
|
|
device_printf(sc->sc_dev, "%s: unhandled code (%d)\n", __func__, code);
|
2014-06-04 09:18:13 +00:00
|
|
|
break;
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_rx_multi_event(struct rsu_softc *sc, uint8_t *buf, int len)
|
|
|
|
{
|
|
|
|
struct r92s_fw_cmd_hdr *cmd;
|
|
|
|
int cmdsz;
|
|
|
|
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX, "%s: Rx events len=%d\n", __func__, len);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Skip Rx status. */
|
|
|
|
buf += sizeof(struct r92s_rx_stat);
|
|
|
|
len -= sizeof(struct r92s_rx_stat);
|
|
|
|
|
|
|
|
/* Process all events. */
|
|
|
|
for (;;) {
|
|
|
|
/* Check that command header fits. */
|
|
|
|
if (__predict_false(len < sizeof(*cmd)))
|
|
|
|
break;
|
|
|
|
cmd = (struct r92s_fw_cmd_hdr *)buf;
|
|
|
|
/* Check that command payload fits. */
|
|
|
|
cmdsz = le16toh(cmd->len);
|
|
|
|
if (__predict_false(len < sizeof(*cmd) + cmdsz))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Process firmware event. */
|
|
|
|
rsu_rx_event(sc, cmd->code, (uint8_t *)&cmd[1], cmdsz);
|
|
|
|
|
|
|
|
if (!(cmd->seq & R92S_FW_CMD_MORE))
|
|
|
|
break;
|
|
|
|
buf += sizeof(*cmd) + cmdsz;
|
|
|
|
len -= sizeof(*cmd) + cmdsz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int8_t
|
|
|
|
rsu_get_rssi(struct rsu_softc *sc, int rate, void *physt)
|
|
|
|
{
|
|
|
|
static const int8_t cckoff[] = { 14, -2, -20, -40 };
|
|
|
|
struct r92s_rx_phystat *phy;
|
|
|
|
struct r92s_rx_cck *cck;
|
|
|
|
uint8_t rpt;
|
|
|
|
int8_t rssi;
|
|
|
|
|
|
|
|
if (rate <= 3) {
|
|
|
|
cck = (struct r92s_rx_cck *)physt;
|
|
|
|
rpt = (cck->agc_rpt >> 6) & 0x3;
|
|
|
|
rssi = cck->agc_rpt & 0x3e;
|
|
|
|
rssi = cckoff[rpt] - rssi;
|
|
|
|
} else { /* OFDM/HT. */
|
|
|
|
phy = (struct r92s_rx_phystat *)physt;
|
|
|
|
rssi = ((le32toh(phy->phydw1) >> 1) & 0x7f) - 106;
|
|
|
|
}
|
|
|
|
return (rssi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct mbuf *
|
2016-12-03 16:02:53 +00:00
|
|
|
rsu_rx_copy_to_mbuf(struct rsu_softc *sc, struct r92s_rx_stat *stat,
|
|
|
|
int totlen)
|
2013-07-30 02:07:57 +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;
|
2016-12-03 16:02:53 +00:00
|
|
|
struct mbuf *m;
|
|
|
|
uint32_t rxdw0;
|
|
|
|
int pktlen;
|
|
|
|
|
|
|
|
rxdw0 = le32toh(stat->rxdw0);
|
2016-12-06 00:13:49 +00:00
|
|
|
if (__predict_false(rxdw0 & (R92S_RXDW0_CRCERR | R92S_RXDW0_ICVERR))) {
|
2016-12-03 16:02:53 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX,
|
2016-12-06 00:13:49 +00:00
|
|
|
"%s: RX flags error (%s)\n", __func__,
|
|
|
|
rxdw0 & R92S_RXDW0_CRCERR ? "CRC" : "ICV");
|
2016-12-03 16:02:53 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
pktlen = MS(rxdw0, R92S_RXDW0_PKTLEN);
|
|
|
|
if (__predict_false(pktlen < sizeof (struct ieee80211_frame_ack))) {
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX,
|
|
|
|
"%s: frame is too short: %d\n", __func__, pktlen);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = m_get2(totlen, M_NOWAIT, MT_DATA, M_PKTHDR);
|
|
|
|
if (__predict_false(m == NULL)) {
|
2016-12-10 20:19:57 +00:00
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: could not allocate RX mbuf, totlen %d\n",
|
|
|
|
__func__, totlen);
|
2016-12-03 16:02:53 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finalize mbuf. */
|
|
|
|
memcpy(mtod(m, uint8_t *), (uint8_t *)stat, totlen);
|
|
|
|
m->m_pkthdr.len = m->m_len = totlen;
|
|
|
|
|
|
|
|
return (m);
|
|
|
|
fail:
|
|
|
|
counter_u64_add(ic->ic_ierrors, 1);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:30:16 +00:00
|
|
|
static uint32_t
|
|
|
|
rsu_get_tsf_low(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
return (rsu_read_4(sc, R92S_TSFTR));
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
rsu_get_tsf_high(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
return (rsu_read_4(sc, R92S_TSFTR + 4));
|
|
|
|
}
|
|
|
|
|
2016-12-03 16:02:53 +00:00
|
|
|
static struct ieee80211_node *
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
rsu_rx_frame(struct rsu_softc *sc, struct mbuf *m)
|
2016-12-03 16:02:53 +00:00
|
|
|
{
|
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
|
|
|
struct ieee80211_frame_min *wh;
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
struct ieee80211_rx_stats rxs;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct r92s_rx_stat *stat;
|
|
|
|
uint32_t rxdw0, rxdw3;
|
2016-12-06 00:13:49 +00:00
|
|
|
uint8_t cipher, rate;
|
2013-07-30 02:07:57 +00:00
|
|
|
int infosz;
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
int rssi;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2016-12-03 16:02:53 +00:00
|
|
|
stat = mtod(m, struct r92s_rx_stat *);
|
2013-07-30 02:07:57 +00:00
|
|
|
rxdw0 = le32toh(stat->rxdw0);
|
|
|
|
rxdw3 = le32toh(stat->rxdw3);
|
|
|
|
|
|
|
|
rate = MS(rxdw3, R92S_RXDW3_RATE);
|
2016-12-06 00:13:49 +00:00
|
|
|
cipher = MS(rxdw0, R92S_RXDW0_CIPHER);
|
2013-07-30 02:07:57 +00:00
|
|
|
infosz = MS(rxdw0, R92S_RXDW0_INFOSZ) * 8;
|
|
|
|
|
|
|
|
/* Get RSSI from PHY status descriptor if present. */
|
2016-12-04 21:40:49 +00:00
|
|
|
if (infosz != 0 && (rxdw0 & R92S_RXDW0_PHYST))
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
rssi = rsu_get_rssi(sc, rate, &stat[1]);
|
2016-12-04 21:40:49 +00:00
|
|
|
else {
|
|
|
|
/* Cheat and get the last calibrated RSSI */
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
rssi = rsu_hwrssi_to_rssi(sc, sc->sc_currssi);
|
2016-12-04 21:40:49 +00:00
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2016-12-03 16:02:53 +00:00
|
|
|
/* Hardware does Rx TCP checksum offload. */
|
2016-12-11 17:15:25 +00:00
|
|
|
/*
|
|
|
|
* This flag can be set for some other
|
|
|
|
* (e.g., EAPOL) frame types, so don't rely on it.
|
|
|
|
*/
|
2016-12-03 16:02:53 +00:00
|
|
|
if (rxdw3 & R92S_RXDW3_TCPCHKVALID) {
|
2016-12-11 17:15:25 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX,
|
|
|
|
"%s: TCP/IP checksums: %schecked / %schecked\n",
|
|
|
|
__func__,
|
|
|
|
(rxdw3 & R92S_RXDW3_TCPCHKRPT) ? "" : "not ",
|
|
|
|
(rxdw3 & R92S_RXDW3_IPCHKRPT) ? "" : "not ");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'IP header checksum valid' bit will not be set if
|
|
|
|
* the frame was not checked / has incorrect checksum /
|
|
|
|
* does not have checksum (IPv6).
|
|
|
|
*
|
|
|
|
* NB: if DF bit is not set then frame will not be checked.
|
|
|
|
*/
|
|
|
|
if (rxdw3 & R92S_RXDW3_IPCHKRPT) {
|
|
|
|
m->m_pkthdr.csum_flags = CSUM_IP_CHECKED;
|
|
|
|
m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is independent of the above check.
|
|
|
|
*/
|
|
|
|
if (rxdw3 & R92S_RXDW3_TCPCHKRPT) {
|
2016-12-03 16:02:53 +00:00
|
|
|
m->m_pkthdr.csum_flags |= CSUM_DATA_VALID;
|
2016-12-11 17:15:25 +00:00
|
|
|
m->m_pkthdr.csum_flags |= CSUM_PSEUDO_HDR;
|
|
|
|
m->m_pkthdr.csum_data = 0xffff;
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
/* RX flags */
|
|
|
|
|
|
|
|
/* Set channel flags for input path */
|
|
|
|
bzero(&rxs, sizeof(rxs));
|
|
|
|
|
|
|
|
/* normal RSSI */
|
|
|
|
rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI;
|
|
|
|
rxs.c_rssi = rssi;
|
|
|
|
rxs.c_nf = -96;
|
|
|
|
|
|
|
|
/* Rate */
|
2017-11-02 00:17:52 +00:00
|
|
|
if (rate < 12) {
|
|
|
|
rxs.c_rate = ridx2rate[rate];
|
|
|
|
if (RSU_RATE_IS_CCK(rate))
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
rxs.c_pktflags |= IEEE80211_RX_F_CCK;
|
2017-11-02 00:17:52 +00:00
|
|
|
else
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
rxs.c_pktflags |= IEEE80211_RX_F_OFDM;
|
2017-11-02 00:17:52 +00:00
|
|
|
} else {
|
|
|
|
rxs.c_rate = IEEE80211_RATE_MCS | (rate - 12);
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
rxs.c_pktflags |= IEEE80211_RX_F_HT;
|
|
|
|
}
|
|
|
|
|
2017-11-02 00:17:52 +00:00
|
|
|
if (ieee80211_radiotap_active(ic)) {
|
|
|
|
struct rsu_rx_radiotap_header *tap = &sc->sc_rxtap;
|
|
|
|
|
|
|
|
/* Map HW rate index to 802.11 rate. */
|
|
|
|
tap->wr_flags = 0; /* TODO */
|
|
|
|
tap->wr_tsft = rsu_get_tsf_high(sc);
|
|
|
|
if (le32toh(stat->tsf_low) > rsu_get_tsf_low(sc))
|
|
|
|
tap->wr_tsft--;
|
|
|
|
tap->wr_tsft = (uint64_t)htole32(tap->wr_tsft) << 32;
|
|
|
|
tap->wr_tsft += stat->tsf_low;
|
|
|
|
|
|
|
|
tap->wr_rate = rxs.c_rate;
|
|
|
|
tap->wr_dbm_antsignal = rssi;
|
|
|
|
tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq);
|
|
|
|
tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags);
|
|
|
|
};
|
|
|
|
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
(void) ieee80211_add_rx_params(m, &rxs);
|
|
|
|
|
2016-12-03 16:02:53 +00:00
|
|
|
/* Drop descriptor. */
|
|
|
|
m_adj(m, sizeof(*stat) + infosz);
|
|
|
|
wh = mtod(m, struct ieee80211_frame_min *);
|
2016-12-06 00:13:49 +00:00
|
|
|
if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) &&
|
|
|
|
cipher != R92S_KEY_ALGO_NONE) {
|
|
|
|
m->m_flags |= M_WEP;
|
|
|
|
}
|
2016-12-03 16:02:53 +00:00
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX,
|
|
|
|
"%s: Rx frame len %d, rate %d, infosz %d\n",
|
|
|
|
__func__, m->m_len, rate, infosz);
|
|
|
|
|
|
|
|
if (m->m_len >= sizeof(*wh))
|
|
|
|
return (ieee80211_find_rxnode(ic, wh));
|
|
|
|
|
|
|
|
return (NULL);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct mbuf *
|
2015-09-30 05:19:16 +00:00
|
|
|
rsu_rx_multi_frame(struct rsu_softc *sc, uint8_t *buf, int len)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
struct r92s_rx_stat *stat;
|
|
|
|
uint32_t rxdw0;
|
|
|
|
int totlen, pktlen, infosz, npkts;
|
|
|
|
struct mbuf *m, *m0 = NULL, *prevm = NULL;
|
|
|
|
|
2016-12-03 16:02:53 +00:00
|
|
|
/*
|
|
|
|
* don't pass packets to the ieee80211 framework if the driver isn't
|
|
|
|
* RUNNING.
|
|
|
|
*/
|
|
|
|
if (!sc->sc_running)
|
|
|
|
return (NULL);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Get the number of encapsulated frames. */
|
|
|
|
stat = (struct r92s_rx_stat *)buf;
|
|
|
|
npkts = MS(le32toh(stat->rxdw2), R92S_RXDW2_PKTCNT);
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX,
|
|
|
|
"%s: Rx %d frames in one chunk\n", __func__, npkts);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Process all of them. */
|
|
|
|
while (npkts-- > 0) {
|
|
|
|
if (__predict_false(len < sizeof(*stat)))
|
|
|
|
break;
|
|
|
|
stat = (struct r92s_rx_stat *)buf;
|
|
|
|
rxdw0 = le32toh(stat->rxdw0);
|
|
|
|
|
|
|
|
pktlen = MS(rxdw0, R92S_RXDW0_PKTLEN);
|
|
|
|
if (__predict_false(pktlen == 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
infosz = MS(rxdw0, R92S_RXDW0_INFOSZ) * 8;
|
|
|
|
|
|
|
|
/* Make sure everything fits in xfer. */
|
|
|
|
totlen = sizeof(*stat) + infosz + pktlen;
|
|
|
|
if (__predict_false(totlen > len))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Process 802.11 frame. */
|
2016-12-03 16:02:53 +00:00
|
|
|
m = rsu_rx_copy_to_mbuf(sc, stat, totlen);
|
2013-07-30 02:07:57 +00:00
|
|
|
if (m0 == NULL)
|
|
|
|
m0 = m;
|
|
|
|
if (prevm == NULL)
|
|
|
|
prevm = m;
|
|
|
|
else {
|
|
|
|
prevm->m_next = m;
|
|
|
|
prevm = m;
|
|
|
|
}
|
|
|
|
/* Next chunk is 128-byte aligned. */
|
|
|
|
totlen = (totlen + 127) & ~127;
|
|
|
|
buf += totlen;
|
|
|
|
len -= totlen;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (m0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct mbuf *
|
2015-09-30 05:19:16 +00:00
|
|
|
rsu_rxeof(struct usb_xfer *xfer, struct rsu_data *data)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
struct rsu_softc *sc = data->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
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct r92s_rx_stat *stat;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
usbd_xfer_status(xfer, &len, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (__predict_false(len < sizeof(*stat))) {
|
2016-12-10 20:19:57 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RX, "xfer too short %d\n", len);
|
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);
|
2013-07-30 02:07:57 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
/* Determine if it is a firmware C2H event or an 802.11 frame. */
|
|
|
|
stat = (struct r92s_rx_stat *)data->buf;
|
|
|
|
if ((le32toh(stat->rxdw1) & 0x1ff) == 0x1ff) {
|
|
|
|
rsu_rx_multi_event(sc, data->buf, len);
|
|
|
|
/* No packets to process. */
|
|
|
|
return (NULL);
|
|
|
|
} else
|
2015-09-30 05:19:16 +00:00
|
|
|
return (rsu_rx_multi_frame(sc, data->buf, len));
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = usbd_xfer_softc(xfer);
|
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;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct ieee80211_node *ni;
|
|
|
|
struct mbuf *m = NULL, *next;
|
|
|
|
struct rsu_data *data;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
switch (USB_GET_STATE(xfer)) {
|
|
|
|
case USB_ST_TRANSFERRED:
|
|
|
|
data = STAILQ_FIRST(&sc->sc_rx_active);
|
|
|
|
if (data == NULL)
|
|
|
|
goto tr_setup;
|
|
|
|
STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
|
2015-09-30 05:19:16 +00:00
|
|
|
m = rsu_rxeof(xfer, data);
|
2013-07-30 02:07:57 +00:00
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case USB_ST_SETUP:
|
|
|
|
tr_setup:
|
|
|
|
data = STAILQ_FIRST(&sc->sc_rx_inactive);
|
|
|
|
if (data == NULL) {
|
|
|
|
KASSERT(m == NULL, ("mbuf isn't NULL"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next);
|
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next);
|
|
|
|
usbd_xfer_set_frame_data(xfer, 0, data->buf,
|
|
|
|
usbd_xfer_max_len(xfer));
|
|
|
|
usbd_transfer_submit(xfer);
|
|
|
|
/*
|
|
|
|
* To avoid LOR we should unlock our private mutex here to call
|
|
|
|
* ieee80211_input() because here is at the end of a USB
|
|
|
|
* callback and safe to unlock.
|
|
|
|
*/
|
|
|
|
while (m != NULL) {
|
2016-12-03 16:02:53 +00:00
|
|
|
next = m->m_next;
|
|
|
|
m->m_next = NULL;
|
|
|
|
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
ni = rsu_rx_frame(sc, m);
|
2016-12-03 16:02:53 +00:00
|
|
|
RSU_UNLOCK(sc);
|
2015-09-30 05:19:16 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
if (ni != NULL) {
|
2015-09-18 05:03:01 +00:00
|
|
|
if (ni->ni_flags & IEEE80211_NODE_HT)
|
|
|
|
m->m_flags |= M_AMPDU;
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
(void)ieee80211_input_mimo(ni, m);
|
2013-07-30 02:07:57 +00:00
|
|
|
ieee80211_free_node(ni);
|
|
|
|
} else
|
[rsu] convert rsu to use the ieee80211_rx_stats struct to pass up RSSI, PHY and rate information.
I don't yet know which RX descriptor bits map to shortgi, long-gi,
short-preamble, long-preamble, STBC, LDPC, HT40, etc - so I can't
easily add those just yet.
There's apparently no per-frame RX RSSI information exposed so we
also just use the results from the previous calibration task.
This also tidies up how the per-mbuf RSSI is pushed into the frame -
now that it's attached to the mbuf via rx_stats, we don't have to
do any silly hijinx to get it out of the frame processing path.
Tested:
* RTL8712, 1x1 cut 3, STA mode
2016-12-22 21:01:56 +00:00
|
|
|
(void)ieee80211_input_mimo_all(ic, m);
|
2016-12-03 16:02:53 +00:00
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
m = next;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* needs it to the inactive queue due to a error. */
|
|
|
|
data = STAILQ_FIRST(&sc->sc_rx_active);
|
|
|
|
if (data != NULL) {
|
|
|
|
STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
|
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
|
|
|
|
}
|
|
|
|
if (error != USB_ERR_CANCELLED) {
|
|
|
|
usbd_xfer_set_stall(xfer);
|
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);
|
2013-07-30 02:07:57 +00:00
|
|
|
goto tr_setup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_txeof(struct usb_xfer *xfer, struct rsu_data *data)
|
|
|
|
{
|
2015-09-12 23:10:34 +00:00
|
|
|
#ifdef USB_DEBUG
|
|
|
|
struct rsu_softc *sc = usbd_xfer_softc(xfer);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TXDONE, "%s: called; data=%p\n",
|
|
|
|
__func__,
|
|
|
|
data);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
if (data->m) {
|
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
|
|
|
/* XXX status? */
|
|
|
|
ieee80211_tx_complete(data->ni, data->m, 0);
|
2013-07-30 02:07:57 +00:00
|
|
|
data->m = NULL;
|
|
|
|
data->ni = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-05-21 16:52:55 +00:00
|
|
|
rsu_bulk_tx_callback_sub(struct usb_xfer *xfer, usb_error_t error,
|
|
|
|
uint8_t which)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
struct rsu_softc *sc = usbd_xfer_softc(xfer);
|
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;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct rsu_data *data;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
switch (USB_GET_STATE(xfer)) {
|
|
|
|
case USB_ST_TRANSFERRED:
|
2014-05-21 16:52:55 +00:00
|
|
|
data = STAILQ_FIRST(&sc->sc_tx_active[which]);
|
2013-07-30 02:07:57 +00:00
|
|
|
if (data == NULL)
|
|
|
|
goto tr_setup;
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TXDONE, "%s: transfer done %p\n",
|
|
|
|
__func__, data);
|
2014-05-21 16:52:55 +00:00
|
|
|
STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next);
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_txeof(xfer, data);
|
2015-09-18 07:26:34 +00:00
|
|
|
rsu_freebuf(sc, data);
|
2013-07-30 02:07:57 +00:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
case USB_ST_SETUP:
|
|
|
|
tr_setup:
|
2014-05-21 16:52:55 +00:00
|
|
|
data = STAILQ_FIRST(&sc->sc_tx_pending[which]);
|
2013-07-30 02:07:57 +00:00
|
|
|
if (data == NULL) {
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TXDONE,
|
|
|
|
"%s: empty pending queue sc %p\n", __func__, sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-05-21 16:52:55 +00:00
|
|
|
STAILQ_REMOVE_HEAD(&sc->sc_tx_pending[which], next);
|
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_tx_active[which], data, next);
|
2013-07-30 02:07:57 +00:00
|
|
|
usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen);
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TXDONE,
|
|
|
|
"%s: submitting transfer %p\n",
|
|
|
|
__func__,
|
|
|
|
data);
|
2013-07-30 02:07:57 +00:00
|
|
|
usbd_transfer_submit(xfer);
|
|
|
|
break;
|
|
|
|
default:
|
2014-05-21 16:52:55 +00:00
|
|
|
data = STAILQ_FIRST(&sc->sc_tx_active[which]);
|
|
|
|
if (data != NULL) {
|
|
|
|
STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next);
|
|
|
|
rsu_txeof(xfer, data);
|
2015-09-18 07:26:34 +00:00
|
|
|
rsu_freebuf(sc, data);
|
2013-07-30 02:07:57 +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
|
|
|
counter_u64_add(ic->ic_oerrors, 1);
|
2014-05-21 16:52:55 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
if (error != USB_ERR_CANCELLED) {
|
|
|
|
usbd_xfer_set_stall(xfer);
|
|
|
|
goto tr_setup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-09-30 05:19:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX TODO: if the queue is low, flush out FF TX frames.
|
|
|
|
* Remember to unlock the driver for now; net80211 doesn't
|
|
|
|
* defer it for us.
|
|
|
|
*/
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
2014-05-21 16:52:55 +00:00
|
|
|
static void
|
2014-06-04 09:18:13 +00:00
|
|
|
rsu_bulk_tx_callback_be_bk(struct usb_xfer *xfer, usb_error_t error)
|
2014-05-21 16:52:55 +00:00
|
|
|
{
|
2015-09-21 02:30:22 +00:00
|
|
|
struct rsu_softc *sc = usbd_xfer_softc(xfer);
|
|
|
|
|
2014-06-04 09:18:13 +00:00
|
|
|
rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_BE_BK);
|
2015-09-21 02:30:22 +00:00
|
|
|
|
|
|
|
/* This kicks the TX taskqueue */
|
|
|
|
rsu_start(sc);
|
2014-05-21 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-04 09:18:13 +00:00
|
|
|
rsu_bulk_tx_callback_vi_vo(struct usb_xfer *xfer, usb_error_t error)
|
2014-05-21 16:52:55 +00:00
|
|
|
{
|
2015-09-21 02:30:22 +00:00
|
|
|
struct rsu_softc *sc = usbd_xfer_softc(xfer);
|
|
|
|
|
2014-06-04 09:18:13 +00:00
|
|
|
rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_VI_VO);
|
2015-09-21 02:30:22 +00:00
|
|
|
|
|
|
|
/* This kicks the TX taskqueue */
|
|
|
|
rsu_start(sc);
|
2014-05-21 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
2015-09-17 03:19:09 +00:00
|
|
|
static void
|
|
|
|
rsu_bulk_tx_callback_h2c(struct usb_xfer *xfer, usb_error_t error)
|
|
|
|
{
|
2015-09-21 02:30:22 +00:00
|
|
|
struct rsu_softc *sc = usbd_xfer_softc(xfer);
|
|
|
|
|
2015-09-17 03:19:09 +00:00
|
|
|
rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_H2C);
|
2015-09-21 02:30:22 +00:00
|
|
|
|
|
|
|
/* This kicks the TX taskqueue */
|
|
|
|
rsu_start(sc);
|
2015-09-17 03:19:09 +00:00
|
|
|
}
|
|
|
|
|
2015-09-26 07:25:53 +00:00
|
|
|
/*
|
|
|
|
* Transmit the given frame.
|
|
|
|
*
|
|
|
|
* This doesn't free the node or mbuf upon failure.
|
|
|
|
*/
|
2013-07-30 02:07:57 +00:00
|
|
|
static int
|
|
|
|
rsu_tx_start(struct rsu_softc *sc, struct ieee80211_node *ni,
|
2014-05-21 16:52:55 +00:00
|
|
|
struct mbuf *m0, struct rsu_data *data)
|
2013-07-30 02:07:57 +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;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct ieee80211_frame *wh;
|
|
|
|
struct ieee80211_key *k = NULL;
|
|
|
|
struct r92s_tx_desc *txd;
|
2016-12-06 00:13:49 +00:00
|
|
|
uint8_t type, cipher;
|
2015-09-17 04:45:29 +00:00
|
|
|
int prio = 0;
|
2014-05-21 16:52:55 +00:00
|
|
|
uint8_t which;
|
|
|
|
int hasqos;
|
|
|
|
int xferlen;
|
2015-09-17 04:45:29 +00:00
|
|
|
int qid;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
|
|
|
|
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX, "%s: data=%p, m=%p\n",
|
|
|
|
__func__, data, m0);
|
|
|
|
|
2014-01-08 08:06:56 +00:00
|
|
|
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
|
2013-07-30 02:07:57 +00:00
|
|
|
k = ieee80211_crypto_encap(ni, m0);
|
|
|
|
if (k == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"ieee80211_crypto_encap returns NULL.\n");
|
|
|
|
/* XXX we don't expect the fragmented frames */
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
wh = mtod(m0, struct ieee80211_frame *);
|
|
|
|
}
|
2015-09-17 04:45:29 +00:00
|
|
|
/* If we have QoS then use it */
|
|
|
|
/* XXX TODO: mbuf WME/PRI versus TID? */
|
|
|
|
if (IEEE80211_QOS_HAS_SEQ(wh)) {
|
|
|
|
/* Has QoS */
|
|
|
|
prio = M_WME_GETAC(m0);
|
|
|
|
which = rsu_wme_ac_xfer_map[prio];
|
|
|
|
hasqos = 1;
|
|
|
|
} else {
|
|
|
|
/* Non-QoS TID */
|
|
|
|
/* XXX TODO: tid=0 for non-qos TID? */
|
|
|
|
which = rsu_wme_ac_xfer_map[WME_AC_BE];
|
|
|
|
hasqos = 0;
|
|
|
|
prio = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
qid = rsu_ac2qid[prio];
|
|
|
|
#if 0
|
2013-07-30 02:07:57 +00:00
|
|
|
switch (type) {
|
|
|
|
case IEEE80211_FC0_TYPE_CTL:
|
|
|
|
case IEEE80211_FC0_TYPE_MGT:
|
2014-06-04 09:18:13 +00:00
|
|
|
which = rsu_wme_ac_xfer_map[WME_AC_VO];
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-06-04 09:18:13 +00:00
|
|
|
which = rsu_wme_ac_xfer_map[M_WME_GETAC(m0)];
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
hasqos = 0;
|
2015-09-17 04:45:29 +00:00
|
|
|
#endif
|
2015-09-18 04:12:11 +00:00
|
|
|
|
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX, "%s: pri=%d, which=%d, hasqos=%d\n",
|
|
|
|
__func__,
|
|
|
|
prio,
|
|
|
|
which,
|
|
|
|
hasqos);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Fill Tx descriptor. */
|
|
|
|
txd = (struct r92s_tx_desc *)data->buf;
|
|
|
|
memset(txd, 0, sizeof(*txd));
|
|
|
|
|
|
|
|
txd->txdw0 |= htole32(
|
|
|
|
SM(R92S_TXDW0_PKTLEN, m0->m_pkthdr.len) |
|
|
|
|
SM(R92S_TXDW0_OFFSET, sizeof(*txd)) |
|
|
|
|
R92S_TXDW0_OWN | R92S_TXDW0_FSG | R92S_TXDW0_LSG);
|
|
|
|
|
|
|
|
txd->txdw1 |= htole32(
|
2015-09-17 04:45:29 +00:00
|
|
|
SM(R92S_TXDW1_MACID, R92S_MACID_BSS) | SM(R92S_TXDW1_QSEL, qid));
|
2013-07-30 02:07:57 +00:00
|
|
|
if (!hasqos)
|
|
|
|
txd->txdw1 |= htole32(R92S_TXDW1_NONQOS);
|
2016-12-06 00:13:49 +00:00
|
|
|
if (k != NULL && !(k->wk_flags & IEEE80211_KEY_SWENCRYPT)) {
|
2013-07-30 02:07:57 +00:00
|
|
|
switch (k->wk_cipher->ic_cipher) {
|
|
|
|
case IEEE80211_CIPHER_WEP:
|
|
|
|
cipher = R92S_TXDW1_CIPHER_WEP;
|
|
|
|
break;
|
|
|
|
case IEEE80211_CIPHER_TKIP:
|
|
|
|
cipher = R92S_TXDW1_CIPHER_TKIP;
|
|
|
|
break;
|
|
|
|
case IEEE80211_CIPHER_AES_CCM:
|
|
|
|
cipher = R92S_TXDW1_CIPHER_AES;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cipher = R92S_TXDW1_CIPHER_NONE;
|
|
|
|
}
|
|
|
|
txd->txdw1 |= htole32(
|
|
|
|
SM(R92S_TXDW1_CIPHER, cipher) |
|
2016-12-06 00:13:49 +00:00
|
|
|
SM(R92S_TXDW1_KEYIDX, k->wk_keyix));
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
2015-09-18 04:12:11 +00:00
|
|
|
/* XXX todo: set AGGEN bit if appropriate? */
|
2013-07-30 02:07:57 +00:00
|
|
|
txd->txdw2 |= htole32(R92S_TXDW2_BK);
|
|
|
|
if (IEEE80211_IS_MULTICAST(wh->i_addr1))
|
|
|
|
txd->txdw2 |= htole32(R92S_TXDW2_BMCAST);
|
|
|
|
/*
|
|
|
|
* Firmware will use and increment the sequence number for the
|
2015-09-17 04:45:29 +00:00
|
|
|
* specified priority.
|
2013-07-30 02:07:57 +00:00
|
|
|
*/
|
2015-09-17 04:45:29 +00:00
|
|
|
txd->txdw3 |= htole32(SM(R92S_TXDW3_SEQ, prio));
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
if (ieee80211_radiotap_active_vap(vap)) {
|
|
|
|
struct rsu_tx_radiotap_header *tap = &sc->sc_txtap;
|
|
|
|
|
|
|
|
tap->wt_flags = 0;
|
|
|
|
tap->wt_chan_freq = htole16(ic->ic_curchan->ic_freq);
|
|
|
|
tap->wt_chan_flags = htole16(ic->ic_curchan->ic_flags);
|
|
|
|
ieee80211_radiotap_tx(vap, m0);
|
|
|
|
}
|
2015-09-12 23:10:34 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
xferlen = sizeof(*txd) + m0->m_pkthdr.len;
|
|
|
|
m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&txd[1]);
|
|
|
|
|
|
|
|
data->buflen = xferlen;
|
|
|
|
data->ni = ni;
|
|
|
|
data->m = m0;
|
2014-05-21 16:52:55 +00:00
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2014-05-21 16:52:55 +00:00
|
|
|
/* start transfer, if any */
|
2014-06-04 09:18:13 +00:00
|
|
|
usbd_transfer_start(sc->sc_xfer[which]);
|
2013-07-30 02:07:57 +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
|
|
|
|
rsu_transmit(struct ieee80211com *ic, struct mbuf *m)
|
2013-07-30 02:07:57 +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 rsu_softc *sc = ic->ic_softc;
|
|
|
|
int error;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
RSU_LOCK(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
|
|
|
if (!sc->sc_running) {
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2015-09-26 07:25:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX TODO: ensure that we treat 'm' as a list of frames
|
|
|
|
* to transmit!
|
|
|
|
*/
|
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
|
|
|
error = mbufq_enqueue(&sc->sc_snd, m);
|
|
|
|
if (error) {
|
2015-09-21 02:12:01 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX,
|
|
|
|
"%s: mbufq_enable: failed (%d)\n",
|
|
|
|
__func__,
|
|
|
|
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
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
return (error);
|
|
|
|
}
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(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
|
|
|
|
2015-09-21 02:30:22 +00:00
|
|
|
/* This kicks the TX taskqueue */
|
|
|
|
rsu_start(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
|
|
|
return (0);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
2015-09-21 02:12:01 +00:00
|
|
|
static void
|
|
|
|
rsu_drain_mbufq(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
struct mbuf *m;
|
|
|
|
struct ieee80211_node *ni;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
|
|
|
|
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
|
|
|
|
m->m_pkthdr.rcvif = NULL;
|
|
|
|
ieee80211_free_node(ni);
|
|
|
|
m_freem(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static void
|
2015-09-21 02:30:22 +00:00
|
|
|
_rsu_start(struct rsu_softc *sc)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_node *ni;
|
|
|
|
struct rsu_data *bf;
|
2014-05-21 16:52:55 +00:00
|
|
|
struct mbuf *m;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
RSU_ASSERT_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
|
|
|
while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
|
|
|
|
bf = rsu_getbuf(sc);
|
|
|
|
if (bf == NULL) {
|
2015-09-21 02:12:01 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX,
|
|
|
|
"%s: failed to get buffer\n", __func__);
|
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_prepend(&sc->sc_snd, m);
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
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
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
|
|
|
|
m->m_pkthdr.rcvif = 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
|
|
|
if (rsu_tx_start(sc, ni, m, bf) != 0) {
|
2015-09-21 02:12:01 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX,
|
|
|
|
"%s: failed to transmit\n", __func__);
|
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);
|
2015-09-18 07:26:34 +00:00
|
|
|
rsu_freebuf(sc, bf);
|
2013-07-30 02:07:57 +00:00
|
|
|
ieee80211_free_node(ni);
|
2015-09-26 07:25:53 +00:00
|
|
|
m_freem(m);
|
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
|
|
|
break;
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-21 02:30:22 +00:00
|
|
|
static void
|
|
|
|
rsu_start(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
|
|
|
|
taskqueue_enqueue(taskqueue_thread, &sc->tx_task);
|
|
|
|
}
|
|
|
|
|
2016-12-11 17:15:25 +00:00
|
|
|
static int
|
|
|
|
rsu_ioctl_net(struct ieee80211com *ic, u_long cmd, void *data)
|
|
|
|
{
|
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
switch (cmd) {
|
|
|
|
case SIOCSIFCAP:
|
|
|
|
{
|
|
|
|
struct ieee80211vap *vap;
|
|
|
|
int rxmask;
|
|
|
|
|
|
|
|
rxmask = ifr->ifr_reqcap & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
|
|
|
|
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
/* Both RXCSUM bits must be set (or unset). */
|
|
|
|
if (sc->sc_rx_checksum_enable &&
|
|
|
|
rxmask != (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) {
|
|
|
|
rxmask = 0;
|
|
|
|
sc->sc_rx_checksum_enable = 0;
|
|
|
|
rsu_rxfilter_set(sc, R92S_RCR_TCP_OFFLD_EN, 0);
|
|
|
|
} else if (!sc->sc_rx_checksum_enable && rxmask != 0) {
|
|
|
|
rxmask = IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
|
|
|
|
sc->sc_rx_checksum_enable = 1;
|
|
|
|
rsu_rxfilter_set(sc, 0, R92S_RCR_TCP_OFFLD_EN);
|
|
|
|
} else {
|
|
|
|
/* Nothing to do. */
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
|
|
|
IEEE80211_LOCK(ic); /* XXX */
|
|
|
|
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
|
|
|
|
struct ifnet *ifp = vap->iv_ifp;
|
|
|
|
|
|
|
|
ifp->if_capenable &=
|
|
|
|
~(IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
|
|
|
|
ifp->if_capenable |= rxmask;
|
|
|
|
}
|
|
|
|
IEEE80211_UNLOCK(ic);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
error = ENOTTY; /* for net80211 */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (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
|
|
|
static void
|
|
|
|
rsu_parent(struct ieee80211com *ic)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
2015-08-20 05:13:54 +00:00
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
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_nrunning > 0) {
|
2016-12-10 22:31:49 +00:00
|
|
|
if (rsu_init(sc) == 0)
|
|
|
|
ieee80211_start_all(ic);
|
|
|
|
else {
|
|
|
|
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
|
|
|
|
if (vap != NULL)
|
|
|
|
ieee80211_stop(vap);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
2016-12-10 22:31:49 +00:00
|
|
|
} else
|
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
|
|
|
rsu_stop(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Power on sequence for A-cut adapters.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
rsu_power_on_acut(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
uint32_t reg;
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SPS0_CTRL + 1, 0x53);
|
|
|
|
rsu_write_1(sc, R92S_SPS0_CTRL + 0, 0x57);
|
|
|
|
|
|
|
|
/* Enable AFE macro block's bandgap and Mbias. */
|
|
|
|
rsu_write_1(sc, R92S_AFE_MISC,
|
|
|
|
rsu_read_1(sc, R92S_AFE_MISC) |
|
|
|
|
R92S_AFE_MISC_BGEN | R92S_AFE_MISC_MBEN);
|
|
|
|
/* Enable LDOA15 block. */
|
|
|
|
rsu_write_1(sc, R92S_LDOA15_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_LDOA15_CTRL) | R92S_LDA15_EN);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SPS1_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_SPS1_CTRL) | R92S_SPS1_LDEN);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 2000);
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Enable switch regulator block. */
|
|
|
|
rsu_write_1(sc, R92S_SPS1_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_SPS1_CTRL) | R92S_SPS1_SWEN);
|
|
|
|
|
|
|
|
rsu_write_4(sc, R92S_SPS1_CTRL, 0x00a7b267);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_ISO_CTRL + 1) | 0x08);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) | 0x20);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_ISO_CTRL + 1) & ~0x90);
|
|
|
|
|
|
|
|
/* Enable AFE clock. */
|
|
|
|
rsu_write_1(sc, R92S_AFE_XTAL_CTRL + 1,
|
|
|
|
rsu_read_1(sc, R92S_AFE_XTAL_CTRL + 1) & ~0x04);
|
|
|
|
/* Enable AFE PLL macro block. */
|
|
|
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_AFE_PLL_CTRL) | 0x11);
|
|
|
|
/* Attach AFE PLL to MACTOP/BB. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_SYS_ISO_CTRL) & ~0x11);
|
|
|
|
|
|
|
|
/* Switch to 40MHz clock instead of 80MHz. */
|
|
|
|
rsu_write_2(sc, R92S_SYS_CLKR,
|
|
|
|
rsu_read_2(sc, R92S_SYS_CLKR) & ~R92S_SYS_CLKSEL);
|
|
|
|
|
|
|
|
/* Enable MAC clock. */
|
|
|
|
rsu_write_2(sc, R92S_SYS_CLKR,
|
|
|
|
rsu_read_2(sc, R92S_SYS_CLKR) |
|
|
|
|
R92S_MAC_CLK_EN | R92S_SYS_CLK_EN);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_PMC_FSM, 0x02);
|
|
|
|
|
|
|
|
/* Enable digital core and IOREG R/W. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) | 0x08);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) | 0x80);
|
|
|
|
|
|
|
|
/* Switch the control path to firmware. */
|
|
|
|
reg = rsu_read_2(sc, R92S_SYS_CLKR);
|
|
|
|
reg = (reg & ~R92S_SWHW_SEL) | R92S_FWHW_SEL;
|
|
|
|
rsu_write_2(sc, R92S_SYS_CLKR, reg);
|
|
|
|
|
|
|
|
rsu_write_2(sc, R92S_CR, 0x37fc);
|
|
|
|
|
|
|
|
/* Fix USB RX FIFO issue. */
|
|
|
|
rsu_write_1(sc, 0xfe5c,
|
|
|
|
rsu_read_1(sc, 0xfe5c) | 0x80);
|
|
|
|
rsu_write_1(sc, 0x00ab,
|
|
|
|
rsu_read_1(sc, 0x00ab) | 0xc0);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_CLKR,
|
|
|
|
rsu_read_1(sc, R92S_SYS_CLKR) & ~R92S_SYS_CPU_CLKSEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Power on sequence for B-cut and C-cut adapters.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
rsu_power_on_bcut(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
uint32_t reg;
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
/* Prevent eFuse leakage. */
|
|
|
|
rsu_write_1(sc, 0x37, 0xb0);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 10);
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_write_1(sc, 0x37, 0x30);
|
|
|
|
|
|
|
|
/* Switch the control path to hardware. */
|
|
|
|
reg = rsu_read_2(sc, R92S_SYS_CLKR);
|
|
|
|
if (reg & R92S_FWHW_SEL) {
|
|
|
|
rsu_write_2(sc, R92S_SYS_CLKR,
|
|
|
|
reg & ~(R92S_SWHW_SEL | R92S_FWHW_SEL));
|
|
|
|
}
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) & ~0x8c);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SPS0_CTRL + 1, 0x53);
|
|
|
|
rsu_write_1(sc, R92S_SPS0_CTRL + 0, 0x57);
|
|
|
|
|
|
|
|
reg = rsu_read_1(sc, R92S_AFE_MISC);
|
|
|
|
rsu_write_1(sc, R92S_AFE_MISC, reg | R92S_AFE_MISC_BGEN);
|
|
|
|
rsu_write_1(sc, R92S_AFE_MISC, reg | R92S_AFE_MISC_BGEN |
|
|
|
|
R92S_AFE_MISC_MBEN | R92S_AFE_MISC_I32_EN);
|
|
|
|
|
|
|
|
/* Enable PLL. */
|
|
|
|
rsu_write_1(sc, R92S_LDOA15_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_LDOA15_CTRL) | R92S_LDA15_EN);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_LDOV12D_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_LDOV12D_CTRL) | R92S_LDV12_EN);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_ISO_CTRL + 1) | 0x08);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) | 0x20);
|
|
|
|
|
|
|
|
/* Support 64KB IMEM. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_ISO_CTRL + 1) & ~0x97);
|
|
|
|
|
|
|
|
/* Enable AFE clock. */
|
|
|
|
rsu_write_1(sc, R92S_AFE_XTAL_CTRL + 1,
|
|
|
|
rsu_read_1(sc, R92S_AFE_XTAL_CTRL + 1) & ~0x04);
|
|
|
|
/* Enable AFE PLL macro block. */
|
|
|
|
reg = rsu_read_1(sc, R92S_AFE_PLL_CTRL);
|
|
|
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x11);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x51);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x11);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Attach AFE PLL to MACTOP/BB. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL,
|
|
|
|
rsu_read_1(sc, R92S_SYS_ISO_CTRL) & ~0x11);
|
|
|
|
|
|
|
|
/* Switch to 40MHz clock. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_CLKR, 0x00);
|
|
|
|
/* Disable CPU clock and 80MHz SSC. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_CLKR,
|
|
|
|
rsu_read_1(sc, R92S_SYS_CLKR) | 0xa0);
|
|
|
|
/* Enable MAC clock. */
|
|
|
|
rsu_write_2(sc, R92S_SYS_CLKR,
|
|
|
|
rsu_read_2(sc, R92S_SYS_CLKR) |
|
|
|
|
R92S_MAC_CLK_EN | R92S_SYS_CLK_EN);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_PMC_FSM, 0x02);
|
|
|
|
|
|
|
|
/* Enable digital core and IOREG R/W. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) | 0x08);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
|
|
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) | 0x80);
|
|
|
|
|
|
|
|
/* Switch the control path to firmware. */
|
|
|
|
reg = rsu_read_2(sc, R92S_SYS_CLKR);
|
|
|
|
reg = (reg & ~R92S_SWHW_SEL) | R92S_FWHW_SEL;
|
|
|
|
rsu_write_2(sc, R92S_SYS_CLKR, reg);
|
|
|
|
|
|
|
|
rsu_write_2(sc, R92S_CR, 0x37fc);
|
|
|
|
|
|
|
|
/* Fix USB RX FIFO issue. */
|
|
|
|
rsu_write_1(sc, 0xfe5c,
|
|
|
|
rsu_read_1(sc, 0xfe5c) | 0x80);
|
|
|
|
|
|
|
|
rsu_write_1(sc, R92S_SYS_CLKR,
|
|
|
|
rsu_read_1(sc, R92S_SYS_CLKR) & ~R92S_SYS_CPU_CLKSEL);
|
|
|
|
|
|
|
|
rsu_write_1(sc, 0xfe1c, 0x80);
|
|
|
|
|
|
|
|
/* Make sure TxDMA is ready to download firmware. */
|
|
|
|
for (ntries = 0; ntries < 20; ntries++) {
|
|
|
|
reg = rsu_read_1(sc, R92S_TCR);
|
|
|
|
if ((reg & (R92S_TCR_IMEM_CHK_RPT | R92S_TCR_EMEM_CHK_RPT)) ==
|
|
|
|
(R92S_TCR_IMEM_CHK_RPT | R92S_TCR_EMEM_CHK_RPT))
|
|
|
|
break;
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
if (ntries == 20) {
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RESET | RSU_DEBUG_TX,
|
|
|
|
"%s: TxDMA is not ready\n",
|
|
|
|
__func__);
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Reset TxDMA. */
|
|
|
|
reg = rsu_read_1(sc, R92S_CR);
|
|
|
|
rsu_write_1(sc, R92S_CR, reg & ~R92S_CR_TXDMA_EN);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
rsu_write_1(sc, R92S_CR, reg | R92S_CR_TXDMA_EN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_power_off(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
/* Turn RF off. */
|
|
|
|
rsu_write_1(sc, R92S_RF_CTRL, 0x00);
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 5);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Turn MAC off. */
|
|
|
|
/* Switch control path. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_CLKR + 1, 0x38);
|
|
|
|
/* Reset MACTOP. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1, 0x70);
|
|
|
|
rsu_write_1(sc, R92S_PMC_FSM, 0x06);
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL + 0, 0xf9);
|
|
|
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL + 1, 0xe8);
|
|
|
|
|
|
|
|
/* Disable AFE PLL. */
|
|
|
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL, 0x00);
|
|
|
|
/* Disable A15V. */
|
|
|
|
rsu_write_1(sc, R92S_LDOA15_CTRL, 0x54);
|
|
|
|
/* Disable eFuse 1.2V. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1, 0x50);
|
|
|
|
rsu_write_1(sc, R92S_LDOV12D_CTRL, 0x24);
|
|
|
|
/* Enable AFE macro block's bandgap and Mbias. */
|
|
|
|
rsu_write_1(sc, R92S_AFE_MISC, 0x30);
|
|
|
|
/* Disable 1.6V LDO. */
|
|
|
|
rsu_write_1(sc, R92S_SPS0_CTRL + 0, 0x56);
|
|
|
|
rsu_write_1(sc, R92S_SPS0_CTRL + 1, 0x43);
|
2015-09-22 05:48:51 +00:00
|
|
|
|
|
|
|
/* Firmware - tell it to switch things off */
|
|
|
|
(void) rsu_set_fw_power_state(sc, RSU_PWR_OFF);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-07-30 16:17:30 +00:00
|
|
|
rsu_fw_loadsection(struct rsu_softc *sc, const uint8_t *buf, int len)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
2014-06-04 09:18:13 +00:00
|
|
|
const uint8_t which = rsu_wme_ac_xfer_map[WME_AC_VO];
|
2013-07-30 02:07:57 +00:00
|
|
|
struct rsu_data *data;
|
|
|
|
struct r92s_tx_desc *txd;
|
|
|
|
int mlen;
|
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
data = rsu_getbuf(sc);
|
|
|
|
if (data == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
txd = (struct r92s_tx_desc *)data->buf;
|
|
|
|
memset(txd, 0, sizeof(*txd));
|
|
|
|
if (len <= RSU_TXBUFSZ - sizeof(*txd)) {
|
|
|
|
/* Last chunk. */
|
|
|
|
txd->txdw0 |= htole32(R92S_TXDW0_LINIP);
|
|
|
|
mlen = len;
|
|
|
|
} else
|
|
|
|
mlen = RSU_TXBUFSZ - sizeof(*txd);
|
|
|
|
txd->txdw0 |= htole32(SM(R92S_TXDW0_PKTLEN, mlen));
|
|
|
|
memcpy(&txd[1], buf, mlen);
|
|
|
|
data->buflen = sizeof(*txd) + mlen;
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_TX | RSU_DEBUG_FW | RSU_DEBUG_RESET,
|
|
|
|
"%s: starting transfer %p\n",
|
|
|
|
__func__, data);
|
2014-05-21 16:52:55 +00:00
|
|
|
STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which], data, next);
|
2013-07-30 02:07:57 +00:00
|
|
|
buf += mlen;
|
|
|
|
len -= mlen;
|
|
|
|
}
|
2014-06-04 09:18:13 +00:00
|
|
|
usbd_transfer_start(sc->sc_xfer[which]);
|
2013-07-30 02:07:57 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-07-30 16:45:28 +00:00
|
|
|
CTASSERT(sizeof(size_t) >= sizeof(uint32_t));
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
static int
|
|
|
|
rsu_load_firmware(struct rsu_softc *sc)
|
|
|
|
{
|
2013-07-30 16:17:30 +00:00
|
|
|
const struct r92s_fw_hdr *hdr;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct r92s_fw_priv *dmem;
|
2015-09-18 04:12:11 +00:00
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
2013-07-30 16:17:30 +00:00
|
|
|
const uint8_t *imem, *emem;
|
2017-07-30 16:45:28 +00:00
|
|
|
uint32_t imemsz, ememsz;
|
2013-07-30 02:07:57 +00:00
|
|
|
const struct firmware *fw;
|
|
|
|
size_t size;
|
|
|
|
uint32_t reg;
|
|
|
|
int ntries, error;
|
|
|
|
|
2014-06-04 09:18:13 +00:00
|
|
|
if (rsu_read_1(sc, R92S_TCR) & R92S_TCR_FWRDY) {
|
2015-09-22 02:57:18 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_ANY,
|
2015-09-12 23:10:34 +00:00
|
|
|
"%s: Firmware already loaded\n",
|
|
|
|
__func__);
|
2014-06-04 09:18:13 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
/* Read firmware image from the filesystem. */
|
|
|
|
if ((fw = firmware_get("rsu-rtl8712fw")) == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: failed load firmware of file rsu-rtl8712fw\n",
|
|
|
|
__func__);
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
size = fw->datasize;
|
|
|
|
if (size < sizeof(*hdr)) {
|
|
|
|
device_printf(sc->sc_dev, "firmware too short\n");
|
|
|
|
error = EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
2013-07-30 16:17:30 +00:00
|
|
|
hdr = (const struct r92s_fw_hdr *)fw->data;
|
2013-07-30 02:07:57 +00:00
|
|
|
if (hdr->signature != htole16(0x8712) &&
|
|
|
|
hdr->signature != htole16(0x8192)) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"invalid firmware signature 0x%x\n",
|
|
|
|
le16toh(hdr->signature));
|
|
|
|
error = EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
2016-12-10 20:19:57 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_FW, "FW V%d %02x-%02x %02x:%02x\n",
|
|
|
|
le16toh(hdr->version), hdr->month, hdr->day, hdr->hour,
|
|
|
|
hdr->minute);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Make sure that driver and firmware are in sync. */
|
|
|
|
if (hdr->privsz != htole32(sizeof(*dmem))) {
|
|
|
|
device_printf(sc->sc_dev, "unsupported firmware image\n");
|
|
|
|
error = EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Get FW sections sizes. */
|
|
|
|
imemsz = le32toh(hdr->imemsz);
|
|
|
|
ememsz = le32toh(hdr->sramsz);
|
|
|
|
/* Check that all FW sections fit in image. */
|
2017-07-30 16:45:28 +00:00
|
|
|
if (imemsz > (size_t)(size - sizeof(*hdr)) ||
|
|
|
|
ememsz > (size_t)(size - sizeof(*hdr) - imemsz)) {
|
2013-07-30 02:07:57 +00:00
|
|
|
device_printf(sc->sc_dev, "firmware too short\n");
|
|
|
|
error = EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
2013-07-30 16:17:30 +00:00
|
|
|
imem = (const uint8_t *)&hdr[1];
|
2013-07-30 02:07:57 +00:00
|
|
|
emem = imem + imemsz;
|
|
|
|
|
|
|
|
/* Load IMEM section. */
|
|
|
|
error = rsu_fw_loadsection(sc, imem, imemsz);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not load firmware section %s\n", "IMEM");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Wait for load to complete. */
|
2014-05-22 06:28:09 +00:00
|
|
|
for (ntries = 0; ntries != 50; ntries++) {
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 10);
|
2014-06-04 09:18:13 +00:00
|
|
|
reg = rsu_read_1(sc, R92S_TCR);
|
2013-07-30 02:07:57 +00:00
|
|
|
if (reg & R92S_TCR_IMEM_CODE_DONE)
|
|
|
|
break;
|
|
|
|
}
|
2014-05-22 06:28:09 +00:00
|
|
|
if (ntries == 50) {
|
|
|
|
device_printf(sc->sc_dev, "timeout waiting for IMEM transfer\n");
|
2013-07-30 02:07:57 +00:00
|
|
|
error = ETIMEDOUT;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Load EMEM section. */
|
|
|
|
error = rsu_fw_loadsection(sc, emem, ememsz);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not load firmware section %s\n", "EMEM");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Wait for load to complete. */
|
2014-05-22 12:01:43 +00:00
|
|
|
for (ntries = 0; ntries != 50; ntries++) {
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 10);
|
2013-07-30 02:07:57 +00:00
|
|
|
reg = rsu_read_2(sc, R92S_TCR);
|
|
|
|
if (reg & R92S_TCR_EMEM_CODE_DONE)
|
|
|
|
break;
|
|
|
|
}
|
2014-05-22 12:01:43 +00:00
|
|
|
if (ntries == 50) {
|
2014-05-22 06:28:09 +00:00
|
|
|
device_printf(sc->sc_dev, "timeout waiting for EMEM transfer\n");
|
2013-07-30 02:07:57 +00:00
|
|
|
error = ETIMEDOUT;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Enable CPU. */
|
|
|
|
rsu_write_1(sc, R92S_SYS_CLKR,
|
|
|
|
rsu_read_1(sc, R92S_SYS_CLKR) | R92S_SYS_CPU_CLKSEL);
|
|
|
|
if (!(rsu_read_1(sc, R92S_SYS_CLKR) & R92S_SYS_CPU_CLKSEL)) {
|
|
|
|
device_printf(sc->sc_dev, "could not enable system clock\n");
|
|
|
|
error = EIO;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
rsu_write_2(sc, R92S_SYS_FUNC_EN,
|
|
|
|
rsu_read_2(sc, R92S_SYS_FUNC_EN) | R92S_FEN_CPUEN);
|
|
|
|
if (!(rsu_read_2(sc, R92S_SYS_FUNC_EN) & R92S_FEN_CPUEN)) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not enable microcontroller\n");
|
|
|
|
error = EIO;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Wait for CPU to initialize. */
|
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
2014-06-04 09:18:13 +00:00
|
|
|
if (rsu_read_1(sc, R92S_TCR) & R92S_TCR_IMEM_RDY)
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
if (ntries == 100) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"timeout waiting for microcontroller\n");
|
|
|
|
error = ETIMEDOUT;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update DMEM section before loading. */
|
2013-07-30 16:17:30 +00:00
|
|
|
dmem = __DECONST(struct r92s_fw_priv *, &hdr->priv);
|
2013-07-30 02:07:57 +00:00
|
|
|
memset(dmem, 0, sizeof(*dmem));
|
|
|
|
dmem->hci_sel = R92S_HCI_SEL_USB | R92S_HCI_SEL_8172;
|
2015-09-17 03:42:18 +00:00
|
|
|
dmem->nendpoints = sc->sc_nendpoints;
|
2015-09-22 02:57:18 +00:00
|
|
|
dmem->chip_version = sc->cut;
|
2015-09-29 06:56:00 +00:00
|
|
|
dmem->rf_config = sc->sc_rftype;
|
2013-07-30 02:07:57 +00:00
|
|
|
dmem->vcs_type = R92S_VCS_TYPE_AUTO;
|
|
|
|
dmem->vcs_mode = R92S_VCS_MODE_RTS_CTS;
|
2015-09-17 03:42:18 +00:00
|
|
|
dmem->turbo_mode = 0;
|
2015-09-18 04:12:11 +00:00
|
|
|
dmem->bw40_en = !! (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40);
|
|
|
|
dmem->amsdu2ampdu_en = !! (sc->sc_ht);
|
|
|
|
dmem->ampdu_en = !! (sc->sc_ht);
|
|
|
|
dmem->agg_offload = !! (sc->sc_ht);
|
2015-09-17 07:04:15 +00:00
|
|
|
dmem->qos_en = 1;
|
2015-09-22 02:57:18 +00:00
|
|
|
dmem->ps_offload = 1;
|
|
|
|
dmem->lowpower_mode = 1; /* XXX TODO: configurable? */
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Load DMEM section. */
|
|
|
|
error = rsu_fw_loadsection(sc, (uint8_t *)dmem, sizeof(*dmem));
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"could not load firmware section %s\n", "DMEM");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Wait for load to complete. */
|
|
|
|
for (ntries = 0; ntries < 100; ntries++) {
|
2014-06-04 09:18:13 +00:00
|
|
|
if (rsu_read_1(sc, R92S_TCR) & R92S_TCR_DMEM_CODE_DONE)
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
if (ntries == 100) {
|
|
|
|
device_printf(sc->sc_dev, "timeout waiting for %s transfer\n",
|
|
|
|
"DMEM");
|
|
|
|
error = ETIMEDOUT;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Wait for firmware readiness. */
|
|
|
|
for (ntries = 0; ntries < 60; ntries++) {
|
2014-06-04 09:18:13 +00:00
|
|
|
if (!(rsu_read_1(sc, R92S_TCR) & R92S_TCR_FWRDY))
|
2013-07-30 02:07:57 +00:00
|
|
|
break;
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(sc, 1);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
if (ntries == 60) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"timeout waiting for firmware readiness\n");
|
|
|
|
error = ETIMEDOUT;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
fail:
|
|
|
|
firmware_put(fw, FIRMWARE_UNLOAD);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
rsu_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
|
|
|
|
const struct ieee80211_bpf_params *params)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = ni->ni_ic;
|
2015-08-20 05:13:54 +00:00
|
|
|
struct rsu_softc *sc = ic->ic_softc;
|
2013-07-30 02:07:57 +00:00
|
|
|
struct rsu_data *bf;
|
|
|
|
|
|
|
|
/* 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_running) {
|
2013-07-30 02:07:57 +00:00
|
|
|
m_freem(m);
|
|
|
|
return (ENETDOWN);
|
|
|
|
}
|
|
|
|
RSU_LOCK(sc);
|
|
|
|
bf = rsu_getbuf(sc);
|
|
|
|
if (bf == NULL) {
|
|
|
|
m_freem(m);
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
2014-05-21 16:52:55 +00:00
|
|
|
if (rsu_tx_start(sc, ni, m, bf) != 0) {
|
2015-09-26 07:25:53 +00:00
|
|
|
m_freem(m);
|
2015-09-18 07:26:34 +00:00
|
|
|
rsu_freebuf(sc, bf);
|
2013-07-30 02:07:57 +00:00
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2016-12-10 18:47:13 +00:00
|
|
|
static void
|
|
|
|
rsu_rxfilter_init(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
uint32_t reg;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
/* Setup multicast filter. */
|
|
|
|
rsu_set_multi(sc);
|
|
|
|
|
|
|
|
/* Adjust Rx filter. */
|
|
|
|
reg = rsu_read_4(sc, R92S_RCR);
|
|
|
|
reg &= ~R92S_RCR_AICV;
|
|
|
|
reg |= R92S_RCR_APP_PHYSTS;
|
2016-12-11 17:15:25 +00:00
|
|
|
if (sc->sc_rx_checksum_enable)
|
|
|
|
reg |= R92S_RCR_TCP_OFFLD_EN;
|
2016-12-10 18:47:13 +00:00
|
|
|
rsu_write_4(sc, R92S_RCR, reg);
|
|
|
|
|
|
|
|
/* Update dynamic Rx filter parts. */
|
|
|
|
rsu_rxfilter_refresh(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_rxfilter_set(struct rsu_softc *sc, uint32_t clear, uint32_t set)
|
|
|
|
{
|
|
|
|
/* NB: firmware can touch this register too. */
|
|
|
|
rsu_write_4(sc, R92S_RCR,
|
|
|
|
(rsu_read_4(sc, R92S_RCR) & ~clear) | set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rsu_rxfilter_refresh(struct rsu_softc *sc)
|
|
|
|
{
|
|
|
|
struct ieee80211com *ic = &sc->sc_ic;
|
|
|
|
uint32_t mask_all, mask_min;
|
|
|
|
|
|
|
|
RSU_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
/* NB: RCR_AMF / RXFLTMAP_MGT are used by firmware. */
|
|
|
|
mask_all = R92S_RCR_ACF | R92S_RCR_AAP;
|
|
|
|
mask_min = R92S_RCR_APM;
|
|
|
|
if (sc->sc_vap_is_running)
|
|
|
|
mask_min |= R92S_RCR_CBSSID;
|
|
|
|
else
|
|
|
|
mask_all |= R92S_RCR_ADF;
|
|
|
|
|
|
|
|
if (ic->ic_opmode == IEEE80211_M_MONITOR) {
|
|
|
|
uint16_t rxfltmap;
|
|
|
|
if (sc->sc_vap_is_running)
|
|
|
|
rxfltmap = 0;
|
|
|
|
else
|
|
|
|
rxfltmap = R92S_RXFLTMAP_MGT_DEF;
|
|
|
|
rsu_write_2(sc, R92S_RXFLTMAP_MGT, rxfltmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ic->ic_promisc == 0 && ic->ic_opmode != IEEE80211_M_MONITOR)
|
|
|
|
rsu_rxfilter_set(sc, mask_all, mask_min);
|
|
|
|
else
|
|
|
|
rsu_rxfilter_set(sc, mask_min, mask_all);
|
|
|
|
}
|
|
|
|
|
2016-12-10 22:31:49 +00:00
|
|
|
static int
|
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
|
|
|
rsu_init(struct rsu_softc *sc)
|
2013-07-30 02:07:57 +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);
|
|
|
|
uint8_t macaddr[IEEE80211_ADDR_LEN];
|
2013-07-30 02:07:57 +00:00
|
|
|
int error;
|
2014-05-22 06:28:09 +00:00
|
|
|
int i;
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2016-12-10 22:31:49 +00:00
|
|
|
RSU_LOCK(sc);
|
|
|
|
|
|
|
|
if (sc->sc_running) {
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
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
|
|
|
|
2015-09-21 02:12:01 +00:00
|
|
|
/* Ensure the mbuf queue is drained */
|
|
|
|
rsu_drain_mbufq(sc);
|
|
|
|
|
2015-09-22 02:57:18 +00:00
|
|
|
/* Reset power management state. */
|
|
|
|
rsu_write_1(sc, R92S_USB_HRPWM, 0);
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Power on adapter. */
|
|
|
|
if (sc->cut == 1)
|
|
|
|
rsu_power_on_acut(sc);
|
|
|
|
else
|
|
|
|
rsu_power_on_bcut(sc);
|
2014-06-04 09:18:13 +00:00
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
/* Load firmware. */
|
|
|
|
error = rsu_load_firmware(sc);
|
|
|
|
if (error != 0)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
rsu_write_4(sc, R92S_CR,
|
|
|
|
rsu_read_4(sc, R92S_CR) & ~0xff000000);
|
|
|
|
|
|
|
|
/* Use 128 bytes pages. */
|
|
|
|
rsu_write_1(sc, 0x00b5,
|
|
|
|
rsu_read_1(sc, 0x00b5) | 0x01);
|
|
|
|
/* Enable USB Rx aggregation. */
|
|
|
|
rsu_write_1(sc, 0x00bd,
|
|
|
|
rsu_read_1(sc, 0x00bd) | 0x80);
|
|
|
|
/* Set USB Rx aggregation threshold. */
|
|
|
|
rsu_write_1(sc, 0x00d9, 0x01);
|
|
|
|
/* Set USB Rx aggregation timeout (1.7ms/4). */
|
|
|
|
rsu_write_1(sc, 0xfe5b, 0x04);
|
|
|
|
/* Fix USB Rx FIFO issue. */
|
|
|
|
rsu_write_1(sc, 0xfe5c,
|
|
|
|
rsu_read_1(sc, 0xfe5c) | 0x80);
|
|
|
|
|
|
|
|
/* Set 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
|
|
|
IEEE80211_ADDR_COPY(macaddr, vap ? vap->iv_myaddr : ic->ic_macaddr);
|
|
|
|
rsu_write_region_1(sc, R92S_MACID, macaddr, IEEE80211_ADDR_LEN);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2014-05-20 15:47:37 +00:00
|
|
|
/* It really takes 1.5 seconds for the firmware to boot: */
|
2016-12-10 22:31:49 +00:00
|
|
|
usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(2000));
|
2013-07-30 02:07:57 +00:00
|
|
|
|
2015-09-12 23:10:34 +00:00
|
|
|
RSU_DPRINTF(sc, RSU_DEBUG_RESET, "%s: setting MAC address to %s\n",
|
|
|
|
__func__,
|
|
|
|
ether_sprintf(macaddr));
|
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
|
|
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_MAC_ADDRESS, macaddr,
|
2013-07-30 02:07:57 +00:00
|
|
|
IEEE80211_ADDR_LEN);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not set MAC address\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2016-12-10 18:47:13 +00:00
|
|
|
/* Initialize Rx filter. */
|
|
|
|
rsu_rxfilter_init(sc);
|
2016-11-27 18:06:03 +00:00
|
|
|
|
2015-09-13 04:41:13 +00:00
|
|
|
/* Set PS mode fully active */
|
2015-09-22 02:57:18 +00:00
|
|
|
error = rsu_set_fw_power_state(sc, RSU_PWR_ACTIVE);
|
2013-07-30 02:07:57 +00:00
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->sc_dev, "could not set PS mode\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
/* Install static keys (if any). */
|
|
|
|
error = rsu_reinit_static_keys(sc);
|
|
|
|
if (error != 0)
|
|
|
|
goto fail;
|
|
|
|
|
2016-11-27 12:03:34 +00:00
|
|
|
sc->sc_extra_scan = 0;
|
2013-07-30 02:07:57 +00:00
|
|
|
usbd_transfer_start(sc->sc_xfer[RSU_BULK_RX]);
|
|
|
|
|
|
|
|
/* We're ready to go. */
|
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_running = 1;
|
2016-12-10 22:31:49 +00:00
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
|
|
|
return (0);
|
2013-07-30 02:07:57 +00:00
|
|
|
fail:
|
2014-05-22 06:28:09 +00:00
|
|
|
/* Need to stop all failed transfers, if any */
|
|
|
|
for (i = 0; i != RSU_N_TRANSFER; i++)
|
|
|
|
usbd_transfer_stop(sc->sc_xfer[i]);
|
2016-12-10 22:31:49 +00:00
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
|
|
|
|
return (error);
|
2013-07-30 02:07:57 +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
|
|
|
rsu_stop(struct rsu_softc *sc)
|
2013-07-30 02:07:57 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2016-12-10 22:31:49 +00:00
|
|
|
RSU_LOCK(sc);
|
|
|
|
if (!sc->sc_running) {
|
|
|
|
RSU_UNLOCK(sc);
|
|
|
|
return;
|
|
|
|
}
|
2015-09-22 05:48:51 +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_running = 0;
|
2016-12-10 18:47:13 +00:00
|
|
|
sc->sc_vap_is_running = 0;
|
2013-07-30 02:07:57 +00:00
|
|
|
sc->sc_calibrating = 0;
|
|
|
|
taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL);
|
2015-09-21 02:30:22 +00:00
|
|
|
taskqueue_cancel(taskqueue_thread, &sc->tx_task, NULL);
|
2013-07-30 02:07:57 +00:00
|
|
|
|
|
|
|
/* Power off adapter. */
|
|
|
|
rsu_power_off(sc);
|
|
|
|
|
2016-12-06 00:13:49 +00:00
|
|
|
/*
|
|
|
|
* CAM is not accessible after shutdown;
|
|
|
|
* all entries are marked (by firmware?) as invalid.
|
|
|
|
*/
|
|
|
|
memset(sc->free_keys_bmap, 0, sizeof(sc->free_keys_bmap));
|
|
|
|
memset(sc->keys_bmap, 0, sizeof(sc->keys_bmap));
|
|
|
|
|
2013-07-30 02:07:57 +00:00
|
|
|
for (i = 0; i < RSU_N_TRANSFER; i++)
|
|
|
|
usbd_transfer_stop(sc->sc_xfer[i]);
|
2015-09-21 02:12:01 +00:00
|
|
|
|
|
|
|
/* Ensure the mbuf queue is drained */
|
|
|
|
rsu_drain_mbufq(sc);
|
2016-12-10 22:31:49 +00:00
|
|
|
RSU_UNLOCK(sc);
|
2013-07-30 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
2015-09-17 03:01:19 +00:00
|
|
|
/*
|
|
|
|
* Note: usb_pause_mtx() actually releases the mutex before calling pause(),
|
|
|
|
* which breaks any kind of driver serialisation.
|
|
|
|
*/
|
2014-05-20 15:47:37 +00:00
|
|
|
static void
|
2015-09-17 03:01:19 +00:00
|
|
|
rsu_ms_delay(struct rsu_softc *sc, int ms)
|
2014-05-20 15:47:37 +00:00
|
|
|
{
|
2015-09-17 03:01:19 +00:00
|
|
|
|
|
|
|
//usb_pause_mtx(&sc->sc_mtx, hz / 1000);
|
|
|
|
DELAY(ms * 1000);
|
2014-05-20 15:47:37 +00:00
|
|
|
}
|