rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.
Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw
Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.
Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes
2016-10-17 20:38:24 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
|
|
|
|
* Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org>
|
|
|
|
* Copyright (c) 2015-2016 Andriy Voskoboinyk <avos@FreeBSD.org>
|
|
|
|
*
|
|
|
|
* 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$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/taskqueue.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/endian.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
|
|
|
#include <net80211/ieee80211_radiotap.h>
|
|
|
|
|
|
|
|
#include <dev/rtwn/if_rtwnvar.h>
|
|
|
|
|
|
|
|
#include <dev/rtwn/if_rtwn_beacon.h>
|
|
|
|
#include <dev/rtwn/if_rtwn_debug.h>
|
|
|
|
#include <dev/rtwn/if_rtwn_tx.h>
|
|
|
|
|
|
|
|
#include <dev/rtwn/rtl8192c/r92c_reg.h>
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
rtwn_reset_beacon_valid(struct rtwn_softc *sc, int id)
|
|
|
|
{
|
|
|
|
|
|
|
|
KASSERT (id == 0 || id == 1, ("wrong port id %d\n", id));
|
|
|
|
|
2016-11-06 23:13:13 +00:00
|
|
|
/* XXX cannot be cleared on RTL8188CE */
|
rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.
Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw
Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.
Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes
2016-10-17 20:38:24 +00:00
|
|
|
rtwn_setbits_1_shift(sc, sc->bcn_status_reg[id],
|
|
|
|
R92C_TDECTRL_BCN_VALID, 0, 2);
|
|
|
|
|
|
|
|
RTWN_DPRINTF(sc, RTWN_DEBUG_BEACON,
|
|
|
|
"%s: 'beacon valid' bit for vap %d was unset\n",
|
|
|
|
__func__, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rtwn_check_beacon_valid(struct rtwn_softc *sc, int id)
|
|
|
|
{
|
|
|
|
uint16_t reg;
|
|
|
|
int ntries;
|
|
|
|
|
|
|
|
if (id == RTWN_VAP_ID_INVALID)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
reg = sc->bcn_status_reg[id];
|
|
|
|
for (ntries = 0; ntries < 10; ntries++) {
|
|
|
|
if (rtwn_read_4(sc, reg) & R92C_TDECTRL_BCN_VALID) {
|
|
|
|
RTWN_DPRINTF(sc, RTWN_DEBUG_BEACON,
|
|
|
|
"%s: beacon for vap %d was recognized\n",
|
|
|
|
__func__, id);
|
|
|
|
break;
|
|
|
|
}
|
2016-11-06 23:13:13 +00:00
|
|
|
rtwn_delay(sc, sc->bcn_check_interval);
|
rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.
Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw
Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.
Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes
2016-10-17 20:38:24 +00:00
|
|
|
}
|
|
|
|
if (ntries == 10)
|
|
|
|
return (ETIMEDOUT);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rtwn_switch_bcnq(struct rtwn_softc *sc, int id)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (sc->cur_bcnq_id != id) {
|
|
|
|
/* Wait until any previous transmit completes. */
|
|
|
|
(void) rtwn_check_beacon_valid(sc, sc->cur_bcnq_id);
|
|
|
|
|
|
|
|
/* Change current port. */
|
|
|
|
rtwn_beacon_select(sc, id);
|
|
|
|
sc->cur_bcnq_id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset 'beacon valid' bit. */
|
|
|
|
rtwn_reset_beacon_valid(sc, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rtwn_setup_beacon(struct rtwn_softc *sc, struct ieee80211_node *ni)
|
|
|
|
{
|
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
|
|
|
struct rtwn_vap *uvp = RTWN_VAP(vap);
|
|
|
|
struct mbuf *m;
|
|
|
|
|
|
|
|
RTWN_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
if (ni->ni_chan == IEEE80211_CHAN_ANYC)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
m = ieee80211_beacon_alloc(ni);
|
|
|
|
if (m == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: could not allocate beacon frame\n", __func__);
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
|
2016-11-06 23:13:13 +00:00
|
|
|
if (uvp->bcn_mbuf != NULL) {
|
|
|
|
rtwn_beacon_unload(sc, uvp->id);
|
rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.
Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw
Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.
Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes
2016-10-17 20:38:24 +00:00
|
|
|
m_freem(uvp->bcn_mbuf);
|
2016-11-06 23:13:13 +00:00
|
|
|
}
|
rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.
Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw
Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.
Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes
2016-10-17 20:38:24 +00:00
|
|
|
|
|
|
|
uvp->bcn_mbuf = m;
|
|
|
|
|
|
|
|
rtwn_beacon_set_rate(sc, &uvp->bcn_desc.txd[0],
|
|
|
|
IEEE80211_IS_CHAN_5GHZ(ni->ni_chan));
|
|
|
|
|
|
|
|
return (rtwn_tx_beacon_check(sc, uvp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Push a beacon frame into the chip. Beacon will
|
|
|
|
* be repeated by the chip every R92C_BCN_INTERVAL.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
rtwn_tx_beacon(struct rtwn_softc *sc, struct rtwn_vap *uvp)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
RTWN_ASSERT_LOCKED(sc);
|
|
|
|
|
|
|
|
RTWN_DPRINTF(sc, RTWN_DEBUG_BEACON,
|
|
|
|
"%s: sending beacon for vap %d\n", __func__, uvp->id);
|
|
|
|
|
|
|
|
error = rtwn_tx_start(sc, NULL, uvp->bcn_mbuf, &uvp->bcn_desc.txd[0],
|
|
|
|
IEEE80211_FC0_TYPE_MGT, uvp->id);
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rtwn_update_beacon(struct ieee80211vap *vap, int item)
|
|
|
|
{
|
|
|
|
struct rtwn_softc *sc = vap->iv_ic->ic_softc;
|
|
|
|
struct rtwn_vap *uvp = RTWN_VAP(vap);
|
|
|
|
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
|
|
|
|
struct ieee80211_node *ni = vap->iv_bss;
|
|
|
|
int mcast = 0;
|
|
|
|
|
|
|
|
RTWN_LOCK(sc);
|
|
|
|
if (uvp->bcn_mbuf == NULL) {
|
|
|
|
uvp->bcn_mbuf = ieee80211_beacon_alloc(ni);
|
|
|
|
if (uvp->bcn_mbuf == NULL) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: could not allocate beacon frame\n", __func__);
|
|
|
|
RTWN_UNLOCK(sc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-11-06 23:13:13 +00:00
|
|
|
rtwn_beacon_update_begin(sc, vap);
|
rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.
Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw
Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.
Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes
2016-10-17 20:38:24 +00:00
|
|
|
RTWN_UNLOCK(sc);
|
|
|
|
|
|
|
|
if (item == IEEE80211_BEACON_TIM)
|
|
|
|
mcast = 1; /* XXX */
|
|
|
|
|
|
|
|
setbit(bo->bo_flags, item);
|
|
|
|
ieee80211_beacon_update(ni, uvp->bcn_mbuf, mcast);
|
|
|
|
|
|
|
|
RTWN_LOCK(sc);
|
|
|
|
rtwn_tx_beacon(sc, uvp);
|
2016-11-06 23:13:13 +00:00
|
|
|
rtwn_beacon_update_end(sc, vap);
|
rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.
Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw
Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.
Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes
2016-10-17 20:38:24 +00:00
|
|
|
RTWN_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rtwn_tx_beacon_check(struct rtwn_softc *sc, struct rtwn_vap *uvp)
|
|
|
|
{
|
|
|
|
int ntries, error;
|
|
|
|
|
|
|
|
for (ntries = 0; ntries < 5; ntries++) {
|
|
|
|
rtwn_reset_beacon_valid(sc, uvp->id);
|
|
|
|
|
|
|
|
error = rtwn_tx_beacon(sc, uvp);
|
|
|
|
if (error != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
error = rtwn_check_beacon_valid(sc, uvp->id);
|
|
|
|
if (error == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ntries == 5) {
|
|
|
|
device_printf(sc->sc_dev,
|
|
|
|
"%s: cannot push beacon into chip, error %d!\n",
|
|
|
|
__func__, error);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|