ralinkwifi: Upgrade to FreeBSD 12.

This commit is contained in:
Augustin Cavalier 2019-01-10 17:40:08 -05:00
parent c8ba6df4ed
commit db7b74600c
10 changed files with 85 additions and 113 deletions

View File

@ -16,7 +16,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/if_ral_pci.c 287197 2015-08-27 08:56:39Z glebius $");
__FBSDID("$FreeBSD: releng/12.0/sys/dev/ral/if_ral_pci.c 338951 2018-09-26 19:41:00Z imp $");
/*
* PCI/Cardbus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
@ -178,6 +178,8 @@ static driver_t ral_pci_driver = {
static devclass_t ral_devclass;
DRIVER_MODULE(ral, pci, ral_pci_driver, ral_devclass, NULL, NULL);
MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, ral, ral_pci_ids,
nitems(ral_pci_ids) - 1);
static int
ral_pci_probe(device_t dev)

View File

@ -1,4 +1,4 @@
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2560.c 300752 2016-05-26 16:05:19Z avos $ */
/* $FreeBSD: releng/12.0/sys/dev/ral/rt2560.c 330688 2018-03-09 11:33:56Z avos $ */
/*-
* Copyright (c) 2005, 2006
@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/rt2560.c 300752 2016-05-26 16:05:19Z avos $");
__FBSDID("$FreeBSD: releng/12.0/sys/dev/ral/rt2560.c 330688 2018-03-09 11:33:56Z avos $");
/*-
* Ralink Technology RT2560 chipset driver
@ -1520,7 +1520,7 @@ rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0,
desc = &sc->prioq.desc[sc->prioq.cur];
data = &sc->prioq.data[sc->prioq.cur];
rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate;
rate = ni->ni_txparms->mgmtrate;
wh = mtod(m0, struct ieee80211_frame *);
@ -1596,38 +1596,18 @@ rt2560_sendprot(struct rt2560_softc *sc,
const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate)
{
struct ieee80211com *ic = ni->ni_ic;
const struct ieee80211_frame *wh;
struct rt2560_tx_desc *desc;
struct rt2560_tx_data *data;
struct mbuf *mprot;
int protrate, ackrate, pktlen, flags, isshort, error;
uint16_t dur;
int protrate, flags, error;
bus_dma_segment_t segs[RT2560_MAX_SCATTER];
int nsegs;
KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY,
("protection %d", prot));
wh = mtod(m, const struct ieee80211_frame *);
pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN;
protrate = ieee80211_ctl_rate(ic->ic_rt, rate);
ackrate = ieee80211_ack_rate(ic->ic_rt, rate);
isshort = (ic->ic_flags & IEEE80211_F_SHPREAMBLE) != 0;
dur = ieee80211_compute_duration(ic->ic_rt, pktlen, rate, isshort)
+ ieee80211_ack_duration(ic->ic_rt, rate, isshort);
flags = RT2560_TX_MORE_FRAG;
if (prot == IEEE80211_PROT_RTSCTS) {
/* NB: CTS is the same size as an ACK */
dur += ieee80211_ack_duration(ic->ic_rt, rate, isshort);
flags |= RT2560_TX_ACK;
mprot = ieee80211_alloc_rts(ic, wh->i_addr1, wh->i_addr2, dur);
} else {
mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur);
}
mprot = ieee80211_alloc_prot(ni, m, rate, prot);
if (mprot == NULL) {
/* XXX stat + msg */
if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
device_printf(sc->sc_dev,
"could not allocate mbuf for protection mode %d\n", prot);
return ENOBUFS;
}
@ -1648,6 +1628,11 @@ rt2560_sendprot(struct rt2560_softc *sc,
/* ctl frames are not taken into account for amrr */
data->rix = IEEE80211_FIXED_RATE_NONE;
protrate = ieee80211_ctl_rate(ic->ic_rt, rate);
flags = RT2560_TX_MORE_FRAG;
if (prot == IEEE80211_PROT_RTSCTS)
flags |= RT2560_TX_ACK;
rt2560_setup_tx_desc(sc, desc, flags, mprot->m_pkthdr.len, protrate, 1,
segs->ds_addr);
@ -1748,7 +1733,7 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0,
struct rt2560_tx_desc *desc;
struct rt2560_tx_data *data;
struct ieee80211_frame *wh;
const struct ieee80211_txparam *tp;
const struct ieee80211_txparam *tp = ni->ni_txparms;
struct ieee80211_key *k;
struct mbuf *mnew;
bus_dma_segment_t segs[RT2560_MAX_SCATTER];
@ -1758,11 +1743,10 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0,
wh = mtod(m0, struct ieee80211_frame *);
tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
rate = tp->mcastrate;
} else if (m0->m_flags & M_EAPOL) {
if (m0->m_flags & M_EAPOL) {
rate = tp->mgmtrate;
} else if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
rate = tp->mcastrate;
} else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
rate = tp->ucastrate;
} else {

View File

@ -1,4 +1,4 @@
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2560reg.h 258780 2013-11-30 22:17:27Z eadler $ */
/* $FreeBSD: releng/12.0/sys/dev/ral/rt2560reg.h 258780 2013-11-30 22:17:27Z eadler $ */
/*-
* Copyright (c) 2005, 2006

View File

@ -1,4 +1,4 @@
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2560var.h 289168 2015-10-12 05:21:51Z adrian $ */
/* $FreeBSD: releng/12.0/sys/dev/ral/rt2560var.h 306591 2016-10-02 20:35:55Z avos $ */
/*-
* Copyright (c) 2005, 2006

View File

@ -1,4 +1,4 @@
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2661.c 314222 2017-02-24 21:19:40Z avos $ */
/* $FreeBSD: releng/12.0/sys/dev/ral/rt2661.c 330688 2018-03-09 11:33:56Z avos $ */
/*-
* Copyright (c) 2006
@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/rt2661.c 314222 2017-02-24 21:19:40Z avos $");
__FBSDID("$FreeBSD: releng/12.0/sys/dev/ral/rt2661.c 330688 2018-03-09 11:33:56Z avos $");
/*-
* Ralink Technology RT2561, RT2561S and RT2661 chipset driver
@ -1288,7 +1288,7 @@ rt2661_tx_mgt(struct rt2661_softc *sc, struct mbuf *m0,
desc = &sc->mgtq.desc[sc->mgtq.cur];
data = &sc->mgtq.data[sc->mgtq.cur];
rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate;
rate = ni->ni_txparms->mgmtrate;
wh = mtod(m0, struct ieee80211_frame *);
@ -1363,38 +1363,18 @@ rt2661_sendprot(struct rt2661_softc *sc, int ac,
{
struct ieee80211com *ic = ni->ni_ic;
struct rt2661_tx_ring *txq = &sc->txq[ac];
const struct ieee80211_frame *wh;
struct rt2661_tx_desc *desc;
struct rt2661_tx_data *data;
struct mbuf *mprot;
int protrate, ackrate, pktlen, flags, isshort, error;
uint16_t dur;
int protrate, flags, error;
bus_dma_segment_t segs[RT2661_MAX_SCATTER];
int nsegs;
KASSERT(prot == IEEE80211_PROT_RTSCTS || prot == IEEE80211_PROT_CTSONLY,
("protection %d", prot));
wh = mtod(m, const struct ieee80211_frame *);
pktlen = m->m_pkthdr.len + IEEE80211_CRC_LEN;
protrate = ieee80211_ctl_rate(ic->ic_rt, rate);
ackrate = ieee80211_ack_rate(ic->ic_rt, rate);
isshort = (ic->ic_flags & IEEE80211_F_SHPREAMBLE) != 0;
dur = ieee80211_compute_duration(ic->ic_rt, pktlen, rate, isshort)
+ ieee80211_ack_duration(ic->ic_rt, rate, isshort);
flags = RT2661_TX_MORE_FRAG;
if (prot == IEEE80211_PROT_RTSCTS) {
/* NB: CTS is the same size as an ACK */
dur += ieee80211_ack_duration(ic->ic_rt, rate, isshort);
flags |= RT2661_TX_NEED_ACK;
mprot = ieee80211_alloc_rts(ic, wh->i_addr1, wh->i_addr2, dur);
} else {
mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur);
}
mprot = ieee80211_alloc_prot(ni, m, rate, prot);
if (mprot == NULL) {
/* XXX stat + msg */
if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
device_printf(sc->sc_dev,
"could not allocate mbuf for protection mode %d\n", prot);
return ENOBUFS;
}
@ -1415,6 +1395,11 @@ rt2661_sendprot(struct rt2661_softc *sc, int ac,
/* ctl frames are not taken into account for amrr */
data->rix = IEEE80211_FIXED_RATE_NONE;
protrate = ieee80211_ctl_rate(ic->ic_rt, rate);
flags = RT2661_TX_MORE_FRAG;
if (prot == IEEE80211_PROT_RTSCTS)
flags |= RT2661_TX_NEED_ACK;
rt2661_setup_tx_desc(sc, desc, flags, 0, mprot->m_pkthdr.len,
protrate, segs, 1, ac);
@ -1437,9 +1422,8 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
struct rt2661_tx_desc *desc;
struct rt2661_tx_data *data;
struct ieee80211_frame *wh;
const struct ieee80211_txparam *tp;
const struct ieee80211_txparam *tp = ni->ni_txparms;
struct ieee80211_key *k;
const struct chanAccParams *cap;
struct mbuf *mnew;
bus_dma_segment_t segs[RT2661_MAX_SCATTER];
uint16_t dur;
@ -1448,11 +1432,10 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
wh = mtod(m0, struct ieee80211_frame *);
tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
rate = tp->mcastrate;
} else if (m0->m_flags & M_EAPOL) {
if (m0->m_flags & M_EAPOL) {
rate = tp->mgmtrate;
} else if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
rate = tp->mcastrate;
} else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
rate = tp->ucastrate;
} else {
@ -1461,10 +1444,8 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
}
rate &= IEEE80211_RATE_VAL;
if (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_QOS) {
cap = &ic->ic_wme.wme_chanParams;
noack = cap->cap_wmeParams[ac].wmep_noackPolicy;
}
if (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_QOS)
noack = !! ieee80211_wme_vap_ac_is_noack(vap, ac);
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
k = ieee80211_crypto_encap(ni, m0);
@ -2048,9 +2029,12 @@ static int
rt2661_wme_update(struct ieee80211com *ic)
{
struct rt2661_softc *sc = ic->ic_softc;
struct chanAccParams chp;
const struct wmeParams *wmep;
wmep = ic->ic_wme.wme_chanParams.cap_wmeParams;
ieee80211_wme_ic_getparams(ic, &chp);
wmep = chp.cap_wmeParams;
/* XXX: not sure about shifts. */
/* XXX: the reference driver plays with AC_VI settings too. */

View File

@ -1,4 +1,4 @@
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2661reg.h 258780 2013-11-30 22:17:27Z eadler $ */
/* $FreeBSD: releng/12.0/sys/dev/ral/rt2661reg.h 258780 2013-11-30 22:17:27Z eadler $ */
/*-
* Copyright (c) 2006

View File

@ -1,4 +1,4 @@
/* $FreeBSD: releng/11.1/sys/dev/ral/rt2661var.h 300657 2016-05-25 06:29:23Z sgalabov $ */
/* $FreeBSD: releng/12.0/sys/dev/ral/rt2661var.h 306591 2016-10-02 20:35:55Z avos $ */
/*-
* Copyright (c) 2005

View File

@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/rt2860.c 306851 2016-10-08 16:39:21Z avos $");
__FBSDID("$FreeBSD: releng/12.0/sys/dev/ral/rt2860.c 327479 2018-01-02 00:07:28Z adrian $");
/*-
* Ralink Technology RT2860/RT3090/RT3390/RT3562/RT5390/RT5392 chipset driver
@ -1463,7 +1463,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
struct rt2860_txd *txd;
struct rt2860_txwi *txwi;
struct ieee80211_frame *wh;
const struct ieee80211_txparam *tp;
const struct ieee80211_txparam *tp = ni->ni_txparms;
struct ieee80211_key *k;
struct mbuf *m1;
bus_dma_segment_t segs[RT2860_MAX_SCATTER];
@ -1492,11 +1492,10 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
hdrlen = ieee80211_anyhdrsize(wh);
type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
rate = tp->mcastrate;
} else if (m->m_flags & M_EAPOL) {
if (m->m_flags & M_EAPOL) {
rate = tp->mgmtrate;
} else if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
rate = tp->mcastrate;
} else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
rate = tp->ucastrate;
} else {
@ -3120,10 +3119,13 @@ static int
rt2860_updateedca(struct ieee80211com *ic)
{
struct rt2860_softc *sc = ic->ic_softc;
struct chanAccParams chp;
const struct wmeParams *wmep;
int aci;
wmep = ic->ic_wme.wme_chanParams.cap_wmeParams;
ieee80211_wme_ic_getparams(ic, &chp);
wmep = chp.cap_wmeParams;
/* update MAC TX configuration registers */
for (aci = 0; aci < WME_NUM_AC; aci++) {

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: rt2860reg.h,v 1.30 2010/05/10 18:17:10 damien Exp $
* $FreeBSD: releng/11.1/sys/dev/ral/rt2860reg.h 301575 2016-06-08 02:37:23Z kevlo $
* $FreeBSD: releng/12.0/sys/dev/ral/rt2860reg.h 301575 2016-06-08 02:37:23Z kevlo $
*/
#define RT2860_NOISE_FLOOR -95

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: rt2860var.h,v 1.20 2010/09/07 16:21:42 deraadt Exp $
* $FreeBSD: releng/11.1/sys/dev/ral/rt2860var.h 300657 2016-05-25 06:29:23Z sgalabov $
* $FreeBSD: releng/12.0/sys/dev/ral/rt2860var.h 306591 2016-10-02 20:35:55Z avos $
*/
#define RT2860_TX_RING_COUNT 64