Index: sys/dev/usb/wlan/if_run.c =================================================================== --- sys/dev/usb/wlan/if_run.c +++ sys/dev/usb/wlan/if_run.c @@ -79,8 +79,14 @@ #define RUN_DEBUG #endif +#define IF_RUN_11N +/* #undef IF_RUN_11N */ +#undef IF_RUN_11N_AMDPU +#undef IF_RUN_11N_5GHZ +#define RUN_DEBUG + #ifdef RUN_DEBUG -int run_debug = 0; +int run_debug = 0x00000020; static SYSCTL_NODE(_hw_usb, OID_AUTO, run, CTLFLAG_RW, 0, "USB run"); SYSCTL_INT(_hw_usb_run, OID_AUTO, debug, CTLFLAG_RWTUN, &run_debug, 0, "run debug level"); @@ -808,6 +814,35 @@ IEEE80211_C_WME | /* WME */ IEEE80211_C_WPA; /* WPA1|WPA2(RSN) */ +#ifdef IF_RUN_11N + /* set device HT capabilities */ + /* HT Capabilities strictly for 11ng (we dont support 11ac yet..) */ + + // copied from linux for now + uint16_t cap80211 = 0x03bc; + + ic->ic_htcaps = + IEEE80211_HTC_HT | IEEE80211_HTC_RXMCS32 | IEEE80211_HTC_TXMCS32 | cap80211; + ic->ic_rxstream = 3; + ic->ic_txstream = 3; + + /* IEEE80211_HTC_AMPDU | */ + /* IEEE80211_HTCAP_CHWIDTH40 | */ + /* IEEE80211_HTCAP_SHORTGI40 | */ + /* IEEE80211_HTCAP_GREENFIELD | */ + /* IEEE80211_HTCAP_SMPS_OFF | */ + /* IEEE80211_HTCAP_SHORTGI20 | */ + /* IEEE80211_HTCAP_TXSTBC | */ + /* IEEE80211_HTCAP_RXSTBC_3STREAM | */ + /* IEEE80211_HTCAP_MAXRXAMPDU | */ + /* IEEE80211_HTCAP_MPDUDENSITY_4 | */ + /* IEEE80211_HTC_TXMCS32) & */ + /* (~IEEE80211_HTCAP_LDPC); */ + + /* IEEE80211_HTCAP_DSSSCCK40 | */ + device_printf(sc->sc_dev, "ic_htcaps = 0x%x\n", ic->ic_htcaps); + device_printf(sc->sc_dev, "ic_htcaps has CH40 = %s\n, has SGI40 %s\n", ((ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) == 0) ? "nope" : "Yes", ((ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40) == 0) ? "nope" : "Yes"); +#endif ic->ic_cryptocaps = IEEE80211_CRYPTO_WEP | IEEE80211_CRYPTO_AES_CCM | @@ -972,6 +1007,11 @@ vap->iv_update_beacon = run_update_beacon; vap->iv_max_aid = RT2870_WCID_MAX; +#ifdef IF_RUN_11N_AMDPU + vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K; + vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_2; +#endif + /* * To delete the right key from h/w, we need wcid. * Luckily, there is unused space in ieee80211_key{}, wk_pad, @@ -2701,7 +2741,6 @@ /* only interested in true associations */ if (isnew && ni->ni_associd != 0) { - /* * This function could is called though timeout function. * Need to defer. @@ -2964,7 +3003,7 @@ switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - RUN_DPRINTF(sc, RUN_DEBUG_RECV, + RUN_DPRINTF(sc, RUN_DEBUG_RECV, "rx done, actlen=%d\n", xferlen); if (xferlen < (int)(sizeof(uint32_t) + rxwisize + @@ -3308,6 +3347,15 @@ /* setup TX Wireless Information */ txwi = (struct rt2860_txwi *)(txd + 1); txwi->len = htole16(m->m_pkthdr.len - pad); + +#ifdef IF_RUN_11N + /* Use the HT_MIX PHY in txwi */ + if (IEEE80211_IS_CHAN_HT20(ic->ic_curchan)) { + printf("%s: using mix ht!\n", __func__); + mcs |= RT2860_PHY_HT_MIX; + // XXX: Short preamble? + } else +#endif if (rt2860_rates[ridx].phy == IEEE80211_T_DS) { mcs |= RT2860_PHY_CCK; if (ridx != RT2860_RIDX_CCK1 && @@ -3315,6 +3363,7 @@ mcs |= RT2860_PHY_SHPRE; } else mcs |= RT2860_PHY_OFDM; + txwi->phy = htole16(mcs); /* check if RTS/CTS or CTS-to-self protection is required */ @@ -4845,21 +4894,34 @@ run_getradiocaps(struct ieee80211com *ic, int maxchans, int *nchans, struct ieee80211_channel chans[]) { + +#ifdef IF_RUN_11N_5GHZ // disable 5ghz for now struct run_softc *sc = ic->ic_softc; +#endif uint8_t bands[IEEE80211_MODE_BYTES]; + int ht40 = 0; memset(bands, 0, sizeof(bands)); + +#ifdef IF_RUN_11N + setbit(bands, IEEE80211_MODE_11NG); + setbit(bands, IEEE80211_MODE_11G); + ht40 = 0; +#else setbit(bands, IEEE80211_MODE_11B); setbit(bands, IEEE80211_MODE_11G); - ieee80211_add_channels_default_2ghz(chans, maxchans, nchans, bands, 0); +#endif + ieee80211_add_channels_default_2ghz(chans, maxchans, nchans, bands, ht40); +#ifdef IF_RUN_11N_5GHZ //disable 5ghz for now if (sc->rf_rev == RT2860_RF_2750 || sc->rf_rev == RT2860_RF_2850 || sc->rf_rev == RT3070_RF_3052 || sc->rf_rev == RT3593_RF_3053 || sc->rf_rev == RT5592_RF_5592) { setbit(bands, IEEE80211_MODE_11A); ieee80211_add_channel_list_5ghz(chans, maxchans, nchans, - run_chan_5ghz, nitems(run_chan_5ghz), bands, 0); + run_chan_5ghz, nitems(run_chan_5ghz), bands, ht40); } +#endif } static void @@ -5218,6 +5280,9 @@ { struct ieee80211com *ic = &sc->sc_ic; + RUN_DPRINTF(sc, RUN_DEBUG_ANY, + "Mode in %s is 0x%x\n", __func__, ic->ic_curmode); + /* set basic rates mask */ if (ic->ic_curmode == IEEE80211_MODE_11B) run_write(sc, RT2860_LEGACY_BASIC_RATE, 0x003); Index: sys/dev/usb/wlan/if_runreg.h =================================================================== --- sys/dev/usb/wlan/if_runreg.h +++ sys/dev/usb/wlan/if_runreg.h @@ -781,7 +781,7 @@ #define RT2860_PHY_MODE 0xc000 #define RT2860_PHY_CCK (0 << 14) #define RT2860_PHY_OFDM (1 << 14) -#define RT2860_PHY_HT (2 << 14) +#define RT2860_PHY_HT_MIX (2 << 14) #define RT2860_PHY_HT_GF (3 << 14) #define RT2860_PHY_SGI (1 << 8) #define RT2860_PHY_BW40 (1 << 7) Index: sys/net80211/ieee80211_output.c =================================================================== --- sys/net80211/ieee80211_output.c +++ sys/net80211/ieee80211_output.c @@ -2415,6 +2415,12 @@ frm = ieee80211_add_htcap_ch(frm, vap, c); } + /* If we are in STA mode and have HT caps, advertise them. Don't upgrade to an + HT channel just yet. */ + if ((vap->iv_opmode == IEEE80211_M_STA) && (vap->iv_flags_ht & IEEE80211_FHT_HT)) { + frm = ieee80211_add_htcap_ch(frm, vap, ic->ic_curchan); + } + /* * XXX TODO: need to figure out what/how to update the * VHT channel.