Author: avos
Date: Sun Dec 13 20:48:24 2015
New Revision: 292165
URL: https://svnweb.freebsd.org/changeset/base/292165

Log:
  net80211: remove hardcoded slot time durations from drivers
  
  - Add IEEE80211_GET_SLOTTIME(ic) macro.
  - Use predefined macroses to set slot time.
  
  Approved by:  adrian (mentor)
  Differential Revision:        https://reviews.freebsd.org/D4044

Modified:
  head/sys/dev/bwn/if_bwn.c
  head/sys/dev/otus/if_otus.c
  head/sys/dev/ral/rt2560.c
  head/sys/dev/ral/rt2661.c
  head/sys/dev/ral/rt2860.c
  head/sys/dev/usb/wlan/if_rum.c
  head/sys/dev/usb/wlan/if_run.c
  head/sys/dev/usb/wlan/if_ural.c
  head/sys/dev/usb/wlan/if_urtw.c
  head/sys/dev/usb/wlan/if_urtwn.c
  head/sys/net80211/ieee80211_phy.h

Modified: head/sys/dev/bwn/if_bwn.c
==============================================================================
--- head/sys/dev/bwn/if_bwn.c   Sun Dec 13 20:31:36 2015        (r292164)
+++ head/sys/dev/bwn/if_bwn.c   Sun Dec 13 20:48:24 2015        (r292165)
@@ -2721,8 +2721,7 @@ bwn_updateslot(struct ieee80211com *ic)
        BWN_LOCK(sc);
        if (sc->sc_flags & BWN_FLAG_RUNNING) {
                mac = (struct bwn_mac *)sc->sc_curmac;
-               bwn_set_slot_time(mac,
-                   (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20);
+               bwn_set_slot_time(mac, IEEE80211_GET_SLOTTIME(ic));
        }
        BWN_UNLOCK(sc);
 }

Modified: head/sys/dev/otus/if_otus.c
==============================================================================
--- head/sys/dev/otus/if_otus.c Sun Dec 13 20:31:36 2015        (r292164)
+++ head/sys/dev/otus/if_otus.c Sun Dec 13 20:48:24 2015        (r292165)
@@ -2423,7 +2423,7 @@ otus_updateslot(struct otus_softc *sc)
 
        OTUS_LOCK_ASSERT(sc);
 
-       slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
+       slottime = IEEE80211_GET_SLOTTIME(ic);
        otus_write(sc, AR_MAC_REG_SLOT_TIME, slottime << 10);
        (void)otus_write_barrier(sc);
 }

Modified: head/sys/dev/ral/rt2560.c
==============================================================================
--- head/sys/dev/ral/rt2560.c   Sun Dec 13 20:31:36 2015        (r292164)
+++ head/sys/dev/ral/rt2560.c   Sun Dec 13 20:48:24 2015        (r292165)
@@ -2254,7 +2254,7 @@ rt2560_update_slot(struct ieee80211com *
        uint32_t tmp;
 
 #ifndef FORCE_SLOTTIME
-       slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
+       slottime = IEEE80211_GET_SLOTTIME(ic);
 #else
        /*
         * Setting slot time according to "short slot time" capability
@@ -2272,13 +2272,13 @@ rt2560_update_slot(struct ieee80211com *
         * (-1Mb~-2Mb lower) and the _whole_ BSS would stop using short
         * slot time.
         */
-       slottime = 20;
+       slottime = IEEE80211_DUR_SLOT;
 #endif
 
        /* update the MAC slot boundaries */
        tx_sifs = RAL_SIFS - RT2560_TXRX_TURNAROUND;
        tx_pifs = tx_sifs + slottime;
-       tx_difs = tx_sifs + 2 * slottime;
+       tx_difs = IEEE80211_DUR_DIFS(tx_sifs, slottime);
        eifs = (ic->ic_curmode == IEEE80211_MODE_11B) ? 364 : 60;
 
        tmp = RAL_READ(sc, RT2560_CSR11);

Modified: head/sys/dev/ral/rt2661.c
==============================================================================
--- head/sys/dev/ral/rt2661.c   Sun Dec 13 20:31:36 2015        (r292164)
+++ head/sys/dev/ral/rt2661.c   Sun Dec 13 20:48:24 2015        (r292165)
@@ -2090,7 +2090,7 @@ rt2661_update_slot(struct ieee80211com *
        uint8_t slottime;
        uint32_t tmp;
 
-       slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
+       slottime = IEEE80211_GET_SLOTTIME(ic);
 
        tmp = RAL_READ(sc, RT2661_MAC_CSR9);
        tmp = (tmp & ~0xff) | slottime;

Modified: head/sys/dev/ral/rt2860.c
==============================================================================
--- head/sys/dev/ral/rt2860.c   Sun Dec 13 20:31:36 2015        (r292164)
+++ head/sys/dev/ral/rt2860.c   Sun Dec 13 20:48:24 2015        (r292165)
@@ -3048,7 +3048,7 @@ rt2860_updateslot(struct ieee80211com *i
 
        tmp = RAL_READ(sc, RT2860_BKOFF_SLOT_CFG);
        tmp &= ~0xff;
-       tmp |= (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
+       tmp |= IEEE80211_GET_SLOTTIME(ic);
        RAL_WRITE(sc, RT2860_BKOFF_SLOT_CFG, tmp);
 }
 

Modified: head/sys/dev/usb/wlan/if_rum.c
==============================================================================
--- head/sys/dev/usb/wlan/if_rum.c      Sun Dec 13 20:31:36 2015        
(r292164)
+++ head/sys/dev/usb/wlan/if_rum.c      Sun Dec 13 20:48:24 2015        
(r292165)
@@ -2068,7 +2068,7 @@ rum_update_slot_cb(struct rum_softc *sc,
        struct ieee80211com *ic = &sc->sc_ic;
        uint8_t slottime;
 
-       slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
+       slottime = IEEE80211_GET_SLOTTIME(ic);
 
        rum_modbits(sc, RT2573_MAC_CSR9, slottime, 0xff);
 

Modified: head/sys/dev/usb/wlan/if_run.c
==============================================================================
--- head/sys/dev/usb/wlan/if_run.c      Sun Dec 13 20:31:36 2015        
(r292164)
+++ head/sys/dev/usb/wlan/if_run.c      Sun Dec 13 20:48:24 2015        
(r292165)
@@ -5186,7 +5186,7 @@ run_updateslot_cb(void *arg)
 
        run_read(sc, RT2860_BKOFF_SLOT_CFG, &tmp);
        tmp &= ~0xff;
-       tmp |= (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
+       tmp |= IEEE80211_GET_SLOTTIME(ic);
        run_write(sc, RT2860_BKOFF_SLOT_CFG, tmp);
 }
 

Modified: head/sys/dev/usb/wlan/if_ural.c
==============================================================================
--- head/sys/dev/usb/wlan/if_ural.c     Sun Dec 13 20:31:36 2015        
(r292164)
+++ head/sys/dev/usb/wlan/if_ural.c     Sun Dec 13 20:48:24 2015        
(r292165)
@@ -1771,7 +1771,7 @@ ural_update_slot(struct ural_softc *sc)
        struct ieee80211com *ic = &sc->sc_ic;
        uint16_t slottime, sifs, eifs;
 
-       slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
+       slottime = IEEE80211_GET_SLOTTIME(ic);
 
        /*
         * These settings may sound a bit inconsistent but this is what the

Modified: head/sys/dev/usb/wlan/if_urtw.c
==============================================================================
--- head/sys/dev/usb/wlan/if_urtw.c     Sun Dec 13 20:31:36 2015        
(r292164)
+++ head/sys/dev/usb/wlan/if_urtw.c     Sun Dec 13 20:48:24 2015        
(r292165)
@@ -4291,18 +4291,18 @@ urtw_updateslottask(void *arg, int pendi
        if (sc->sc_flags & URTW_RTL8187B) {
                urtw_write8_m(sc, URTW_SIFS, 0x22);
                if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan))
-                       urtw_write8_m(sc, URTW_SLOT, 0x9);
+                       urtw_write8_m(sc, URTW_SLOT, IEEE80211_DUR_SHSLOT);
                else
-                       urtw_write8_m(sc, URTW_SLOT, 0x14);
+                       urtw_write8_m(sc, URTW_SLOT, IEEE80211_DUR_SLOT);
                urtw_write8_m(sc, URTW_8187B_EIFS, 0x5b);
                urtw_write8_m(sc, URTW_CARRIER_SCOUNT, 0x5b);
        } else {
                urtw_write8_m(sc, URTW_SIFS, 0x22);
                if (sc->sc_state == IEEE80211_S_ASSOC &&
                    ic->ic_flags & IEEE80211_F_SHSLOT)
-                       urtw_write8_m(sc, URTW_SLOT, 0x9);
+                       urtw_write8_m(sc, URTW_SLOT, IEEE80211_DUR_SHSLOT);
                else
-                       urtw_write8_m(sc, URTW_SLOT, 0x14);
+                       urtw_write8_m(sc, URTW_SLOT, IEEE80211_DUR_SLOT);
                if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
                        urtw_write8_m(sc, URTW_DIFS, 0x14);
                        urtw_write8_m(sc, URTW_EIFS, 0x5b - 0x14);

Modified: head/sys/dev/usb/wlan/if_urtwn.c
==============================================================================
--- head/sys/dev/usb/wlan/if_urtwn.c    Sun Dec 13 20:31:36 2015        
(r292164)
+++ head/sys/dev/usb/wlan/if_urtwn.c    Sun Dec 13 20:48:24 2015        
(r292165)
@@ -3621,8 +3621,7 @@ urtwn_wme_update(struct ieee80211com *ic
        int ac;
 
        acm = 0;
-       slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ?
-           IEEE80211_DUR_SHSLOT : IEEE80211_DUR_SLOT;
+       slottime = IEEE80211_GET_SLOTTIME(ic);
 
        URTWN_LOCK(sc);
        for (ac = WME_AC_BE; ac < WME_NUM_AC; ac++) {

Modified: head/sys/net80211/ieee80211_phy.h
==============================================================================
--- head/sys/net80211/ieee80211_phy.h   Sun Dec 13 20:31:36 2015        
(r292164)
+++ head/sys/net80211/ieee80211_phy.h   Sun Dec 13 20:48:24 2015        
(r292165)
@@ -53,6 +53,10 @@
 #define IEEE80211_DUR_SHSLOT   9       /* ERP short slottime */
 #define IEEE80211_DUR_OFDM_SLOT        9       /* OFDM slottime */
 
+#define IEEE80211_GET_SLOTTIME(ic) \
+       ((ic->ic_flags & IEEE80211_F_SHSLOT) ? \
+           IEEE80211_DUR_SHSLOT : IEEE80211_DUR_SLOT)
+
 /*
  * DIFS (microseconds).
  */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to