Page MenuHomeFreeBSD

D22840.id72265.diff
No OneTemporary

D22840.id72265.diff

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");
@@ -366,6 +372,8 @@
static usb_callback_t run_bulk_tx_callback4;
static usb_callback_t run_bulk_tx_callback5;
+
+static void print_run_txwi(struct rt2860_txwi *txwi);
static void run_autoinst(void *, struct usb_device *,
struct usb_attach_arg *);
static int run_driver_loaded(struct module *, int, void *);
@@ -515,7 +523,18 @@
{ 48, 4, IEEE80211_T_OFDM, 8, 44, 44 },
{ 72, 5, IEEE80211_T_OFDM, 8, 40, 40 },
{ 96, 6, IEEE80211_T_OFDM, 8, 40, 40 },
- { 108, 7, IEEE80211_T_OFDM, 8, 40, 40 }
+ { 108, 7, IEEE80211_T_OFDM, 8, 40, 40 },
+#ifdef IF_RUN_11N
+/* What should the rate values be for different MCS values? */
+ {6, 0, IEEE80211_T_HT, 4, 60, 60},
+ {9, 1, IEEE80211_T_HT, 4, 60, 60},
+ {12, 2, IEEE80211_T_HT, 4, 60, 60},
+ {18, 3, IEEE80211_T_HT, 4, 60, 60},
+ {24, 4, IEEE80211_T_HT, 4, 60, 60},
+ {36, 5, IEEE80211_T_HT, 4, 60, 60},
+ {48, 6, IEEE80211_T_HT, 4, 60, 60},
+ {54, 7, IEEE80211_T_HT, 4, 60, 60},
+#endif
};
static const struct {
@@ -808,6 +827,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 = 1;
+ ic->ic_txstream = 1;
+
+ /* 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 +1020,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,
@@ -2065,8 +2118,8 @@
ni = ieee80211_ref_node(vap->iv_bss);
rn = RUN_NODE(ni);
rn->fix_ridx = ridx;
- RUN_DPRINTF(sc, RUN_DEBUG_RATE, "rate=%d, fix_ridx=%d\n",
- rate, rn->fix_ridx);
+ RUN_DPRINTF(sc, RUN_DEBUG_RATE, " %s: rate=%d, fix_ridx=%d\n",
+ __func__, rate, rn->fix_ridx);
ieee80211_free_node(ni);
}
@@ -2607,6 +2660,8 @@
RUN_LOCK(sc);
+ printf("%s: ratectl name %s\n", __func__, vap->iv_rate->ir_name);
+
/* Check for special case */
if (sc->rvp_cnt <= 1 && vap->iv_opmode == IEEE80211_M_STA &&
ni != vap->iv_bss)
@@ -2634,7 +2689,7 @@
le16toh(sta[0].error.fail);
RUN_DPRINTF(sc, RUN_DEBUG_RATE,
- "retrycnt=%d success=%d failcnt=%d\n",
+ "amrr retrycnt=%d success=%d failcnt=%d\n",
txs->nretries, txs->nsuccess, le16toh(sta[0].error.fail));
} else {
wstat = &(sc->wcid_stats[RUN_AID2WCID(ni->ni_associd)]);
@@ -2647,7 +2702,7 @@
txs->nsuccess = (*wstat)[RUN_SUCCESS];
txs->nframes = (*wstat)[RUN_TXCNT];
RUN_DPRINTF(sc, RUN_DEBUG_RATE,
- "retrycnt=%d txcnt=%d success=%d\n",
+ "amrr retrycnt=%d txcnt=%d success=%d\n",
txs->nretries, txs->nframes, txs->nsuccess);
memset(wstat, 0, sizeof(*wstat));
@@ -2655,11 +2710,13 @@
ieee80211_ratectl_tx_update(vap, txs);
rn->amrr_ridx = ieee80211_ratectl_rate(ni, NULL, 0);
+ RUN_DPRINTF(sc, RUN_DEBUG_RATE,
+ "amrr ridx set to %d\n", rn->amrr_ridx);
fail:
RUN_UNLOCK(sc);
+ /* RUN_DPRINTF(sc, RUN_DEBUG_RATE, "amrr_ridx=%d\n", rn->amrr_ridx); */
- RUN_DPRINTF(sc, RUN_DEBUG_RATE, "ridx=%d\n", rn->amrr_ridx);
}
static void
@@ -2701,7 +2758,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 +3020,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 +
@@ -3280,10 +3336,8 @@
uint16_t mcs;
uint8_t ridx = data->ridx;
uint8_t pad;
+ struct ieee80211_node *ni = data->ni;
- /* get MCS code from rate index */
- mcs = rt2860_rates[ridx].mcs;
-
txwisize = (sc->mac_ver == 0x5592) ?
sizeof(*txwi) + sizeof(uint32_t) : sizeof(*txwi);
xferlen = txwisize + m->m_pkthdr.len;
@@ -3308,13 +3362,35 @@
/* setup TX Wireless Information */
txwi = (struct rt2860_txwi *)(txd + 1);
txwi->len = htole16(m->m_pkthdr.len - pad);
+
+ /* get MCS code from rate index */
+ mcs = rt2860_rates[ridx].mcs;
+
+#ifdef IF_RUN_11N
+ /* if (IEEE80211_IS_CHAN_HT20(ic->ic_curchan)) { */
+ /* XXX Can we decide solely based on ridx whether this was
+ an MCS rate or not? It seems unlikely as amrr would consult
+ two different tables rates and htrates and its hard (impossible?)
+ to disambiguate.
+ */
+ if(ni->ni_txrate & IEEE80211_RATE_MCS) {
+ ridx += (RT2860_RIDX_MAX);
+ mcs = rt2860_rates[ridx].mcs;
+ }
+
+ if (rt2860_rates[ridx].phy == IEEE80211_T_HT) {
+ mcs |= RT2860_PHY_HT_MIX;
+ }
+ else
+#endif
if (rt2860_rates[ridx].phy == IEEE80211_T_DS) {
- mcs |= RT2860_PHY_CCK;
- if (ridx != RT2860_RIDX_CCK1 &&
- (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
- mcs |= RT2860_PHY_SHPRE;
+ mcs |= RT2860_PHY_CCK;
+ if (ridx != RT2860_RIDX_CCK1 &&
+ (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
+ mcs |= RT2860_PHY_SHPRE;
} else
- mcs |= RT2860_PHY_OFDM;
+ mcs |= RT2860_PHY_OFDM;
+
txwi->phy = htole16(mcs);
/* check if RTS/CTS or CTS-to-self protection is required */
@@ -3328,6 +3404,8 @@
if (vap->iv_opmode != IEEE80211_M_STA && !IEEE80211_QOS_HAS_SEQ(wh))
txwi->xflags |= RT2860_TX_NSEQ;
+
+ print_run_txwi(txwi);
}
/* This function must be called locked */
@@ -3389,10 +3467,20 @@
RT2860_RIDX_OFDM6 : RT2860_RIDX_CCK1;
ctl_ridx = rt2860_rates[ridx].ctl_ridx;
} else {
- if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
+ if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
+ RUN_DPRINTF(sc, RUN_DEBUG_RATE, "set to fix_ridx ridx=%d\n",
+ rn->fix_ridx);
+
ridx = rn->fix_ridx;
- else
+ }
+ else {
ridx = rn->amrr_ridx;
+ RUN_DPRINTF(sc, RUN_DEBUG_RATE, "set to amrr_ridx ridx=%d\n",
+ rn->amrr_ridx);
+ if(ridx == 0)
+ ridx = 2;
+ }
+
ctl_ridx = rt2860_rates[ridx].ctl_ridx;
}
@@ -3611,7 +3699,7 @@
run_set_tx_desc(sc, data);
- RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "sending prot len=%u rate=%u\n",
+ RUN_DPRINTF(sc, RUN_DEBUG_RATE, "sending prot len=%u rate=%u\n",
m->m_pkthdr.len, rate);
STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next);
@@ -4845,21 +4933,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 +5319,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);
@@ -6306,6 +6410,14 @@
&sc->sc_mtx : NULL, USB_MS_TO_TICKS(ms));
}
+void print_run_txwi(struct rt2860_txwi *txwi) {
+ printf("word0: flags 0x%08x txop 0x%08x phy 0x%016x\n", txwi->flags, txwi->txop, txwi->phy);
+ printf("word1: xflags 0x%08x wcid 0x%08x len 0x%016x\n", txwi->xflags, txwi->wcid, txwi->len);
+ printf("iv: 0x%x\n", txwi->iv);
+ printf("eiv: 0x%x\n", txwi->eiv);
+ printf("-------------\n");
+}
+
static device_method_t run_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, run_match),
@@ -6324,6 +6436,9 @@
DRIVER_MODULE(run, uhub, run_driver, run_devclass, run_driver_loaded, NULL);
MODULE_DEPEND(run, wlan, 1, 1, 1);
+#ifdef IF_RUN_11N
+MODULE_DEPEND(run, wlan_amrr, 1, 1, 1);
+#endif
MODULE_DEPEND(run, usb, 1, 1, 1);
MODULE_DEPEND(run, firmware, 1, 1, 1);
MODULE_VERSION(run, 1);
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.c
===================================================================
--- sys/net80211/ieee80211.c
+++ sys/net80211/ieee80211.c
@@ -120,6 +120,7 @@
/* NB: OFDM rates are handled specially based on mode */
static const struct ieee80211_rateset ieee80211_rateset_11g =
{ 12, { B(2), B(4), B(11), B(22), 12, 18, 24, 36, 48, 72, 96, 108 } };
+ /* { 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 } }; */
#undef B
static int set_vht_extchan(struct ieee80211_channel *c);
@@ -206,6 +207,7 @@
if (IEEE80211_IS_CHAN_VHTG(c))
setbit(ic->ic_modecaps, IEEE80211_MODE_VHT_2GHZ);
}
+
/* initialize candidate channels to all available */
memcpy(ic->ic_chan_active, ic->ic_chan_avail,
sizeof(ic->ic_chan_avail));
@@ -1238,7 +1240,7 @@
if (*nchans >= maxchans)
return (ENOBUFS);
-#if 0
+#if 1
printf("%s: %d: ieee=%d, freq=%d, flags=0x%08x\n",
__func__,
*nchans,
@@ -1272,7 +1274,7 @@
if (*nchans >= maxchans)
return (ENOBUFS);
-#if 0
+#if 1
printf("%s: %d: flags=0x%08x\n",
__func__,
*nchans,
@@ -1630,6 +1632,14 @@
getflags_2ghz(bands, flags, ht40);
KASSERT(flags[0] != 0, ("%s: no correct mode provided\n", __func__));
+#if 1
+ for(int i = 0; flags[i] != 0; i++)
+ printf("%s: flags[%d] = 0x%x\n",
+ __func__,
+ i,
+ flags[i]);
+#endif
+
return (add_chanlist(chans, maxchans, nchans, ieee, nieee, flags));
}
Index: sys/net80211/ieee80211_amrr.c
===================================================================
--- sys/net80211/ieee80211_amrr.c
+++ sys/net80211/ieee80211_amrr.c
@@ -342,6 +342,7 @@
if (!amn)
{
ni->ni_txrate = ni->ni_rates.rs_rates[0];
+ printf("%s returning 0 instead of -1\n", __func__);
return 0;
}
@@ -351,13 +352,16 @@
if (amrr_node_is_11n(ni)) {
/* XXX ew */
rs = (struct ieee80211_rateset *) &ni->ni_htrates;
+ printf("%s checked htrates set!\n", __func__);
} else {
rs = &ni->ni_rates;
+ printf("%s checked REGULAR rates set!\n", __func__);
}
if (is_enough(amn) && (ticks - amn->amn_ticks) > amrr->amrr_interval) {
rix = amrr_update(amrr, amn, ni);
if (rix != amn->amn_rix) {
+ printf("%s if block!\n", __func__);
/* update public rate */
ni->ni_txrate = rs->rs_rates[rix];
/* XXX strip basic rate flag from txrate, if non-11n */
@@ -368,8 +372,10 @@
amn->amn_rix = rix;
}
amn->amn_ticks = ticks;
- } else
+ } else {
+ printf("%s else block!\n", __func__);
rix = amn->amn_rix;
+ }
return rix;
}
@@ -428,6 +434,7 @@
amrr_tx_update(struct ieee80211vap *vap,
struct ieee80211_ratectl_tx_stats *stats)
{
+ printf("inside amrr_tx_update function\n");
if (stats->flags & IEEE80211_RATECTL_TX_STATS_NODE)
amrr_tx_update_cb(stats, stats->ni);
Index: sys/net80211/ieee80211_ht.c
===================================================================
--- sys/net80211/ieee80211_ht.c
+++ sys/net80211/ieee80211_ht.c
@@ -255,7 +255,6 @@
void
ieee80211_ht_vattach(struct ieee80211vap *vap)
{
-
/* driver can override defaults */
vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_8K;
vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_NA;
@@ -2703,7 +2702,6 @@
uint8_t *frm;
int tid, ret;
-
IEEE80211_NOTE(tap->txa_ni->ni_vap, IEEE80211_MSG_11N,
tap->txa_ni,
"%s: called",
@@ -2994,8 +2992,14 @@
txparams |= (ic->ic_txstream - 1) << 2; /* num TX streams */
if (ic->ic_htcaps & IEEE80211_HTC_TXUNEQUAL)
txparams |= 0x16; /* TX unequal modulation sup */
- } else
- txparams = 0;
+ } else {
+ /* lrx337 XXX: This was 0, but changed to 1 in order to mimic rt2x00 behavior.
+ Shouldn't this if else block take into consideration other htcaps like
+ IEEE80211_HTC_TXMCS32 for setting txparams = 0x1 and then check if the
+ num streams are equal for TX RX MCS not equal (is it enough to check the
+ num rx / tx streams to conclude that MCS sets are unequal?). */
+ txparams = 0x0;
+ }
frm[12] = txparams;
}
Index: sys/net80211/ieee80211_node.c
===================================================================
--- sys/net80211/ieee80211_node.c
+++ sys/net80211/ieee80211_node.c
@@ -761,6 +761,11 @@
ieee80211_sync_curchan(struct ieee80211com *ic)
{
struct ieee80211_channel *c;
+ printf("%s: curchan freq %d flags 0x%x\nhtadjflags 0x%x\n",
+ __func__,
+ ic->ic_curchan->ic_freq,
+ ic->ic_curchan->ic_flags,
+ gethtadjustflags(ic));
c = ieee80211_ht_adjust_channel(ic, ic->ic_curchan, gethtadjustflags(ic));
c = ieee80211_vht_adjust_channel(ic, c, getvhtadjustflags(ic));
@@ -773,6 +778,8 @@
ic->ic_set_channel(ic);
ieee80211_radiotap_chan_change(ic);
IEEE80211_LOCK(ic);
+ } else {
+ printf("%s: did not change channel\n", __func__);
}
}
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.

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 28, 4:58 PM (16 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26289980
Default Alt Text
D22840.id72265.diff (15 KB)

Event Timeline