From db7b74600c9304c6780f68f8f6ce728ecc39e538 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 10 Jan 2019 17:40:08 -0500 Subject: [PATCH] ralinkwifi: Upgrade to FreeBSD 12. --- .../wlan/ralinkwifi/dev/ral/if_ral_pci.c | 4 +- .../network/wlan/ralinkwifi/dev/ral/rt2560.c | 70 ++++++--------- .../wlan/ralinkwifi/dev/ral/rt2560reg.h | 2 +- .../wlan/ralinkwifi/dev/ral/rt2560var.h | 2 +- .../network/wlan/ralinkwifi/dev/ral/rt2661.c | 86 ++++++++----------- .../wlan/ralinkwifi/dev/ral/rt2661reg.h | 2 +- .../wlan/ralinkwifi/dev/ral/rt2661var.h | 2 +- .../network/wlan/ralinkwifi/dev/ral/rt2860.c | 26 +++--- .../wlan/ralinkwifi/dev/ral/rt2860reg.h | 2 +- .../wlan/ralinkwifi/dev/ral/rt2860var.h | 2 +- 10 files changed, 85 insertions(+), 113 deletions(-) diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/if_ral_pci.c b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/if_ral_pci.c index 0389f484e0..b41c1afdbf 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/if_ral_pci.c +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/if_ral_pci.c @@ -16,7 +16,7 @@ */ #include -__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) diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560.c b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560.c index 46773321ed..b51805bcce 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560.c +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560.c @@ -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 -__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 @@ -345,7 +345,7 @@ rt2560_detach(void *xsc) { struct rt2560_softc *sc = xsc; struct ieee80211com *ic = &sc->sc_ic; - + rt2560_stop(sc); ieee80211_ifdetach(ic); @@ -464,7 +464,7 @@ rt2560_alloc_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring, ring->cur = ring->next = 0; ring->cur_encrypt = ring->next_encrypt = 0; - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, count * RT2560_TX_DESC_SIZE, 1, count * RT2560_TX_DESC_SIZE, 0, NULL, NULL, &ring->desc_dmat); @@ -496,7 +496,7 @@ rt2560_alloc_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring, goto fail; } - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, RT2560_MAX_SCATTER, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); @@ -608,7 +608,7 @@ rt2560_alloc_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring, ring->cur = ring->next = 0; ring->cur_decrypt = 0; - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, count * RT2560_RX_DESC_SIZE, 1, count * RT2560_RX_DESC_SIZE, 0, NULL, NULL, &ring->desc_dmat); @@ -643,7 +643,7 @@ rt2560_alloc_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring, /* * Pre-allocate Rx buffers and populate Rx ring. */ - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); if (error != 0) { @@ -1294,7 +1294,7 @@ rt2560_beacon_expire(struct rt2560_softc *sc) if (ic->ic_opmode != IEEE80211_M_IBSS && ic->ic_opmode != IEEE80211_M_HOSTAP && ic->ic_opmode != IEEE80211_M_MBSS) - return; + return; data = &sc->bcnq.data[sc->bcnq.next]; /* @@ -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 { @@ -1881,7 +1865,7 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0, } static int -rt2560_transmit(struct ieee80211com *ic, struct mbuf *m) +rt2560_transmit(struct ieee80211com *ic, struct mbuf *m) { struct rt2560_softc *sc = ic->ic_softc; int error; @@ -2125,7 +2109,7 @@ rt2560_set_chan(struct rt2560_softc *sc, struct ieee80211_channel *c) rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040); rt2560_rf_write(sc, RAL_RF4, rt2560_rf5222[i].r4); break; - default: + default: printf("unknown ral rev=%d\n", sc->rf_rev); } @@ -2693,7 +2677,7 @@ rt2560_stop_locked(struct rt2560_softc *sc) /* abort Tx */ RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX); - + /* disable Rx */ RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX); @@ -2703,7 +2687,7 @@ rt2560_stop_locked(struct rt2560_softc *sc) /* disable interrupts */ RAL_WRITE(sc, RT2560_CSR8, 0xffffffff); - + /* reset Tx and Rx rings */ rt2560_reset_tx_ring(sc, &sc->txq); rt2560_reset_tx_ring(sc, &sc->atimq); diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560reg.h b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560reg.h index ae46b5f912..17cc4151be 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560reg.h +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560reg.h @@ -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 diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560var.h b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560var.h index b6559bf58c..70dcca31f3 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560var.h +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2560var.h @@ -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 diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661.c b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661.c index 7fed603048..b3ac92a77e 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661.c +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661.c @@ -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 -__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 @@ -334,7 +334,7 @@ rt2661_detach(void *xsc) { struct rt2661_softc *sc = xsc; struct ieee80211com *ic = &sc->sc_ic; - + RAL_LOCK(sc); rt2661_stop_locked(sc); RAL_UNLOCK(sc); @@ -473,7 +473,7 @@ rt2661_alloc_tx_ring(struct rt2661_softc *sc, struct rt2661_tx_ring *ring, ring->queued = 0; ring->cur = ring->next = ring->stat = 0; - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, count * RT2661_TX_DESC_SIZE, 1, count * RT2661_TX_DESC_SIZE, 0, NULL, NULL, &ring->desc_dmat); @@ -505,7 +505,7 @@ rt2661_alloc_tx_ring(struct rt2661_softc *sc, struct rt2661_tx_ring *ring, goto fail; } - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, RT2661_MAX_SCATTER, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); if (error != 0) { @@ -614,7 +614,7 @@ rt2661_alloc_rx_ring(struct rt2661_softc *sc, struct rt2661_rx_ring *ring, ring->count = count; ring->cur = ring->next = 0; - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, count * RT2661_RX_DESC_SIZE, 1, count * RT2661_RX_DESC_SIZE, 0, NULL, NULL, &ring->desc_dmat); @@ -649,7 +649,7 @@ rt2661_alloc_rx_ring(struct rt2661_softc *sc, struct rt2661_rx_ring *ring, /* * Pre-allocate Rx buffers and populate Rx ring. */ - error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, + error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); if (error != 0) { @@ -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); @@ -1575,7 +1556,7 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0, } static int -rt2661_transmit(struct ieee80211com *ic, struct mbuf *m) +rt2661_transmit(struct ieee80211com *ic, struct mbuf *m) { struct rt2661_softc *sc = ic->ic_softc; int error; @@ -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. */ @@ -2402,23 +2386,23 @@ rt2661_stop_locked(struct rt2661_softc *sc) /* abort Tx (for all 5 Tx rings) */ RAL_WRITE(sc, RT2661_TX_CNTL_CSR, 0x1f << 16); - + /* disable Rx (value remains after reset!) */ tmp = RAL_READ(sc, RT2661_TXRX_CSR0); RAL_WRITE(sc, RT2661_TXRX_CSR0, tmp | RT2661_DISABLE_RX); - + /* reset ASIC */ RAL_WRITE(sc, RT2661_MAC_CSR1, 3); RAL_WRITE(sc, RT2661_MAC_CSR1, 0); - + /* disable interrupts */ RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0xffffffff); RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff); - + /* clear any pending interrupt */ RAL_WRITE(sc, RT2661_INT_SOURCE_CSR, 0xffffffff); RAL_WRITE(sc, RT2661_MCU_INT_SOURCE_CSR, 0xffffffff); - + /* reset Tx and Rx rings */ rt2661_reset_tx_ring(sc, &sc->txq[0]); rt2661_reset_tx_ring(sc, &sc->txq[1]); @@ -2690,7 +2674,7 @@ rt2661_enable_tsf_sync(struct rt2661_softc *sc) static void rt2661_enable_tsf(struct rt2661_softc *sc) { - RAL_WRITE(sc, RT2661_TXRX_CSR9, + RAL_WRITE(sc, RT2661_TXRX_CSR9, (RAL_READ(sc, RT2661_TXRX_CSR9) & 0xff000000) | RT2661_TSF_TICKING | RT2661_TSF_MODE(2)); } diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661reg.h b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661reg.h index 417365d408..70ba439216 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661reg.h +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661reg.h @@ -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 diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661var.h b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661var.h index 0f84d30979..fb609768ab 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661var.h +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2661var.h @@ -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 diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860.c b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860.c index 995589e30e..6b5cce6364 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860.c +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860.c @@ -18,7 +18,7 @@ */ #include -__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 { @@ -1941,7 +1940,7 @@ rt2860_tx_raw(struct rt2860_softc *sc, struct mbuf *m, } static int -rt2860_transmit(struct ieee80211com *ic, struct mbuf *m) +rt2860_transmit(struct ieee80211com *ic, struct mbuf *m) { struct rt2860_softc *sc = ic->ic_softc; int error; @@ -2594,7 +2593,7 @@ rt5390_set_chan(struct rt2860_softc *sc, u_int chan) rf = MIN(rf, 0x5f); if (tmp != rf) rt2860_mcu_cmd(sc, 0x74, (tmp << 8 ) | rf, 0); - + if (sc->mac_ver == 0x5390) { if (chan <= 4) rf = 0x73; @@ -2890,7 +2889,7 @@ rt5390_rf_wakeup(struct rt2860_softc *sc) uint8_t rf; rf = rt3090_rf_read(sc, 1); - rf |= RT3070_RF_BLOCK | RT3070_PLL_PD | RT3070_RX0_PD | + rf |= RT3070_RF_BLOCK | RT3070_PLL_PD | RT3070_RX0_PD | RT3070_TX0_PD; if (sc->mac_ver == 0x5392) rf |= RT3070_RX1_PD | RT3070_TX1_PD; @@ -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++) { @@ -4220,7 +4222,7 @@ rt3090_set_rx_antenna(struct rt2860_softc *sc, int aux) if (aux) { if (sc->mac_ver == 0x5390) { - rt2860_mcu_bbp_write(sc, 152, + rt2860_mcu_bbp_write(sc, 152, rt2860_mcu_bbp_read(sc, 152) & ~0x80); } else { tmp = RAL_READ(sc, RT2860_PCI_EECTRL); @@ -4230,7 +4232,7 @@ rt3090_set_rx_antenna(struct rt2860_softc *sc, int aux) } } else { if (sc->mac_ver == 0x5390) { - rt2860_mcu_bbp_write(sc, 152, + rt2860_mcu_bbp_write(sc, 152, rt2860_mcu_bbp_read(sc, 152) | 0x80); } else { tmp = RAL_READ(sc, RT2860_PCI_EECTRL); diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860reg.h b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860reg.h index 9fc9a747fe..4d5ecd22d5 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860reg.h +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860reg.h @@ -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 diff --git a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860var.h b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860var.h index caf8cee1e7..f5ef90bc12 100644 --- a/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860var.h +++ b/src/add-ons/kernel/drivers/network/wlan/ralinkwifi/dev/ral/rt2860var.h @@ -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