Index: sys/dev/usb/wlan/if_urtwn.c =================================================================== --- sys/dev/usb/wlan/if_urtwn.c +++ sys/dev/usb/wlan/if_urtwn.c @@ -274,6 +274,7 @@ static void urtwn_scan_start(struct ieee80211com *); static void urtwn_scan_end(struct ieee80211com *); static void urtwn_set_channel(struct ieee80211com *); +static int urtwn_wme_update(struct ieee80211com *); static void urtwn_set_promisc(struct urtwn_softc *); static void urtwn_update_promisc(struct ieee80211com *); static void urtwn_update_mcast(struct ieee80211com *); @@ -359,6 +360,16 @@ }, }; +static const struct wme_to_queue { + uint16_t reg; + uint8_t qid; +} wme2queue[WME_NUM_AC] = { + { R92C_EDCA_BE_PARAM, URTWN_BULK_TX_BE}, + { R92C_EDCA_BK_PARAM, URTWN_BULK_TX_BK}, + { R92C_EDCA_VI_PARAM, URTWN_BULK_TX_VI}, + { R92C_EDCA_VO_PARAM, URTWN_BULK_TX_VO} +}; + static int urtwn_match(device_t self) { @@ -448,6 +459,7 @@ | IEEE80211_C_SHSLOT /* short slot time supported */ | IEEE80211_C_BGSCAN /* capable of bg scanning */ | IEEE80211_C_WPA /* 802.11i */ + | IEEE80211_C_WME /* 802.11e */ ; bands = 0; @@ -464,6 +476,7 @@ ic->ic_parent = urtwn_parent; ic->ic_vap_create = urtwn_vap_create; ic->ic_vap_delete = urtwn_vap_delete; + ic->ic_wme.wme_update = urtwn_wme_update; ic->ic_update_promisc = urtwn_update_promisc; ic->ic_update_mcast = urtwn_update_mcast; @@ -1821,8 +1834,8 @@ struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = ni->ni_vap; struct r92c_tx_desc *txd; - uint8_t macid, raid, ridx, subtype, type, qsel; - int ismcast; + uint8_t macid, raid, ridx, subtype, type, tid, qsel; + int hasqos, ismcast; URTWN_ASSERT_LOCKED(sc); @@ -1832,8 +1845,16 @@ wh = mtod(m, struct ieee80211_frame *); type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; + hasqos = IEEE80211_QOS_HAS_SEQ(wh); ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); + /* Select TX ring for this frame. */ + if (hasqos) { + tid = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; + tid &= IEEE80211_QOS_TID; + } else + tid = 0; + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { k = ieee80211_crypto_encap(ni, m); if (k == NULL) { @@ -1862,7 +1883,7 @@ macid = URTWN_MACID_BSS; if (type == IEEE80211_FC0_TYPE_DATA) { - qsel = R92C_TXDW1_QSEL_BE; + qsel = tid % URTWN_MAX_TID; if (!(m->m_flags & M_EAPOL)) { if (ic->ic_curmode != IEEE80211_MODE_11B) { @@ -1917,7 +1938,7 @@ if (ridx <= URTWN_RIDX_CCK11) txd->txdw4 |= htole32(R92C_TXDW4_DRVRATE); - if (!IEEE80211_QOS_HAS_SEQ(wh)) { + if (!hasqos) { /* Use HW sequence numbering for non-QoS frames. */ txd->txdseq = htole16(R92C_TXDSEQ_HWSEQ_EN); } else { @@ -1949,12 +1970,6 @@ struct r92c_tx_desc *txd; uint16_t ac, sum; int i, xferlen; - struct usb_xfer *urtwn_pipes[WME_NUM_AC] = { - sc->sc_xfer[URTWN_BULK_TX_BE], - sc->sc_xfer[URTWN_BULK_TX_BK], - sc->sc_xfer[URTWN_BULK_TX_VI], - sc->sc_xfer[URTWN_BULK_TX_VO] - }; URTWN_ASSERT_LOCKED(sc); @@ -1966,7 +1981,7 @@ xfer = sc->sc_xfer[URTWN_BULK_TX_VO]; break; default: - xfer = urtwn_pipes[ac]; + xfer = sc->sc_xfer[wme2queue[ac].qid]; break; } @@ -3196,6 +3211,43 @@ URTWN_UNLOCK(sc); } +static int +urtwn_wme_update(struct ieee80211com *ic) +{ + const struct wmeParams *wmep = + ic->ic_wme.wme_chanParams.cap_wmeParams; + struct urtwn_softc *sc = ic->ic_softc; + uint8_t aifs, acm, slottime; + int ac; + + acm = 0; + slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? + IEEE80211_DUR_SHSLOT : IEEE80211_DUR_SLOT; + + URTWN_LOCK(sc); + for (ac = WME_AC_BE; ac < WME_NUM_AC; ac++) { + /* AIFS[AC] = AIFSN[AC] * aSlotTime + aSIFSTime. */ + aifs = wmep[ac].wmep_aifsn * slottime + IEEE80211_DUR_SIFS; + urtwn_write_4(sc, wme2queue[ac].reg, + SM(R92C_EDCA_PARAM_TXOP, wmep[ac].wmep_txopLimit) | + SM(R92C_EDCA_PARAM_ECWMIN, wmep[ac].wmep_logcwmin) | + SM(R92C_EDCA_PARAM_ECWMAX, wmep[ac].wmep_logcwmax) | + SM(R92C_EDCA_PARAM_AIFS, aifs)); + if (ac != WME_AC_BE) + acm |= wmep[ac].wmep_acm << ac; + } + + if (acm != 0) + acm |= R92C_ACMHWCTRL_EN; + urtwn_write_1(sc, R92C_ACMHWCTRL, + (urtwn_read_1(sc, R92C_ACMHWCTRL) & ~R92C_ACMHWCTRL_ACM_MASK) | + acm); + + URTWN_UNLOCK(sc); + + return 0; +} + static void urtwn_set_promisc(struct urtwn_softc *sc) { Index: sys/dev/usb/wlan/if_urtwnreg.h =================================================================== --- sys/dev/usb/wlan/if_urtwnreg.h +++ sys/dev/usb/wlan/if_urtwnreg.h @@ -495,6 +495,13 @@ #define R92C_BCN_CTRL_EN_BCN 0x08 #define R92C_BCN_CTRL_DIS_TSF_UDT0 0x10 +/* Bits for R92C_ACMHWCTRL. */ +#define R92C_ACMHWCTRL_EN 0x01 +#define R92C_ACMHWCTRL_BE 0x02 +#define R92C_ACMHWCTRL_VI 0x04 +#define R92C_ACMHWCTRL_VO 0x08 +#define R92C_ACMHWCTRL_ACM_MASK 0x0f + /* Bits for R92C_APSD_CTRL. */ #define R92C_APSD_CTRL_OFF 0x40 #define R92C_APSD_CTRL_OFF_STATUS 0x80 @@ -1018,10 +1025,19 @@ #define R88E_TXDW1_MACID_S 0 #define R92C_TXDW1_AGGEN 0x00000020 #define R92C_TXDW1_AGGBK 0x00000040 + #define R92C_TXDW1_QSEL_M 0x00001f00 #define R92C_TXDW1_QSEL_S 8 -#define R92C_TXDW1_QSEL_BE 0x00 + +#define R92C_TXDW1_QSEL_BE 0x00 /* or 0x03 */ +#define R92C_TXDW1_QSEL_BK 0x01 /* or 0x02 */ +#define R92C_TXDW1_QSEL_VI 0x04 /* or 0x05 */ +#define R92C_TXDW1_QSEL_VO 0x06 /* or 0x07 */ +#define URTWN_MAX_TID 8 + +#define R92C_TXDW1_QSEL_BEACON 0x10 #define R92C_TXDW1_QSEL_MGNT 0x12 + #define R92C_TXDW1_RAID_M 0x000f0000 #define R92C_TXDW1_RAID_S 16 #define R92C_TXDW1_CIPHER_M 0x00c00000 Index: sys/dev/usb/wlan/if_urtwnvar.h =================================================================== --- sys/dev/usb/wlan/if_urtwnvar.h +++ sys/dev/usb/wlan/if_urtwnvar.h @@ -128,7 +128,6 @@ device_t sc_dev; struct usb_device *sc_udev; - int ac2idx[WME_NUM_AC]; u_int sc_flags; #define URTWN_FLAG_CCK_HIPWR 0x01 #define URTWN_DETACHED 0x02