Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev/usb 40MHz support for urtwn.



details:   https://anonhg.NetBSD.org/src-all/rev/5bca197c30f9
branches:  trunk
changeset: 363057:5bca197c30f9
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Thu May 14 20:42:54 2020 +1000

description:
40MHz support for urtwn.

diffstat:

 sys/dev/usb/if_urtwn.c |  37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)

diffs (138 lines):

diff -r b6a576419004 -r 5bca197c30f9 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Thu May 14 16:22:14 2020 +1000
+++ b/sys/dev/usb/if_urtwn.c    Thu May 14 20:42:54 2020 +1000
@@ -324,8 +324,7 @@
 static void    urtwn_r88e_get_txpower(struct urtwn_softc *, size_t, u_int,
                    u_int, uint16_t[]);
 static void    urtwn_set_txpower(struct urtwn_softc *, u_int, u_int);
-static void    urtwn_set_chan(struct urtwn_softc *, struct ieee80211_channel *,
-                   u_int);
+static void    urtwn_set_chan(struct urtwn_softc *, struct ieee80211_channel *);
 static void    urtwn_iq_calib(struct urtwn_softc *, bool);
 static void    urtwn_lc_calib(struct urtwn_softc *);
 static void    urtwn_temp_calib(struct urtwn_softc *);
@@ -521,11 +520,9 @@
 #if 0
            IEEE80211_HTCAP_MAXAMSDU_3839 |     /* max A-MSDU length */
 #endif
-           IEEE80211_HTCAP_SMPS_OFF;           /* SM PS mode disabled */
-#if 0
+           IEEE80211_HTCAP_SMPS_OFF |          /* SM PS mode disabled */
            IEEE80211_HTCAP_CHWIDTH40 |         /* 40 MHz channel width */
            IEEE80211_HTCAP_SHORTGI40;          /* short GI in 40MHz */
-#endif
 
 #ifdef notyet
        ic->ic_cryptocaps =
@@ -3689,7 +3686,7 @@
        DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
 
        mutex_enter(&sc->sc_write_mtx);
-       urtwn_set_chan(sc, ic->ic_curchan, IEEE80211_HTINFO_2NDCHAN_NONE);
+       urtwn_set_chan(sc, ic->ic_curchan);
        mutex_exit(&sc->sc_write_mtx);
 } 
 
@@ -3842,8 +3839,7 @@
                error = ieee80211_ioctl(ifp, cmd, data);
                if (error == ENETRESET &&
                    ic->ic_opmode == IEEE80211_M_MONITOR) {
-                       urtwn_set_chan(sc, ic->ic_curchan,
-                           IEEE80211_HTINFO_2NDCHAN_NONE);
+                       urtwn_set_chan(sc, ic->ic_curchan);
                        error = 0;
                }
                break;
@@ -5050,7 +5046,7 @@
                if (sc->regulatory == 3) {
                        power[ridx] = base->pwr[0][ridx];
                        /* Apply vendor limits. */
-                       if (ht40m != IEEE80211_HTINFO_2NDCHAN_NONE) {
+                       if (ht40m) {
                                maxpow = rom->ht40_max_pwr[group];
                        } else {
                                maxpow = rom->ht20_max_pwr[group];
@@ -5060,7 +5056,7 @@
                                power[ridx] = maxpow;
                        }
                } else if (sc->regulatory == 1) {
-                       if (ht40m == IEEE80211_HTINFO_2NDCHAN_NONE) {
+                       if (!ht40m) {
                                power[ridx] = base->pwr[group][ridx];
                        }
                } else if (sc->regulatory != 2) {
@@ -5097,7 +5093,7 @@
        }
 
        /* Compute per-MCS Tx power. */
-       if (ht40m == IEEE80211_HTINFO_2NDCHAN_NONE) {
+       if (!ht40m) {
                diff = rom->ht20_tx_pwr_diff[group];
                diff = (diff >> (chain * 4)) & 0xf;
                htpow += diff;  /* HT40->HT20 correction. */
@@ -5159,7 +5155,7 @@
                if (sc->regulatory == 3)
                        power[ridx] = base->pwr[0][ridx];
                else if (sc->regulatory == 1) {
-                       if (ht40m == IEEE80211_HTINFO_2NDCHAN_NONE)
+                       if (!ht40m)
                                power[ridx] = base->pwr[group][ridx];
                } else if (sc->regulatory != 2)
                        power[ridx] = base->pwr[0][ridx];
@@ -5211,23 +5207,24 @@
        }
 }
 
-static void __noinline
-urtwn_set_chan(struct urtwn_softc *sc, struct ieee80211_channel *c, u_int ht40m)
+static void
+urtwn_set_chan(struct urtwn_softc *sc, struct ieee80211_channel *c)
 {
        struct ieee80211com *ic = &sc->sc_ic;
-       u_int chan;
+       u_int chan, ht40m;
        size_t i;
 
        chan = ieee80211_chan2ieee(ic, c);      /* XXX center freq! */
+       ht40m = c->ic_flags & IEEE80211_CHAN_HT40;
 
        DPRINTFN(DBG_FN, ("%s: %s: chan=%d\n", device_xname(sc->sc_dev),
            __func__, chan));
 
        KASSERT(mutex_owned(&sc->sc_write_mtx));
 
-       if (ht40m == IEEE80211_HTINFO_2NDCHAN_ABOVE) {
+       if (ht40m == IEEE80211_CHAN_HT40U) {
                chan += 2;
-       } else if (ht40m == IEEE80211_HTINFO_2NDCHAN_BELOW){
+       } else if (ht40m == IEEE80211_CHAN_HT40D){
                chan -= 2;
        }
 
@@ -5241,7 +5238,7 @@
 
        if (ht40m) {
                /* Is secondary channel below or above primary? */
-               int prichlo = (ht40m == IEEE80211_HTINFO_2NDCHAN_ABOVE);
+               int prichlo = (ht40m == IEEE80211_CHAN_HT40U);
                uint32_t reg;
 
                urtwn_write_1(sc, R92C_BWOPMODE,
@@ -5766,7 +5763,7 @@
                urtwn_write_1(sc, 0x15, 0xe9);
 
        /* Set default channel. */
-       urtwn_set_chan(sc, ic->ic_curchan, IEEE80211_HTINFO_2NDCHAN_NONE);
+       urtwn_set_chan(sc, ic->ic_curchan);
 
        /* We're ready to go. */
        ifp->if_flags &= ~IFF_OACTIVE;
@@ -5837,7 +5834,7 @@
        if (ic->ic_opmode != IEEE80211_M_MONITOR)
                return ENETRESET;
 
-       urtwn_set_chan(sc, ic->ic_curchan, IEEE80211_HTINFO_2NDCHAN_NONE);
+       urtwn_set_chan(sc, ic->ic_curchan);
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index