]> xenbits.xensource.com Git - people/liuw/freebsd.git/commitdiff
ath(4): begin fleshing out a "reset type" extension to force cold/warn resets.
authoradrian <adrian@FreeBSD.org>
Mon, 9 Nov 2015 15:59:42 +0000 (15:59 +0000)
committeradrian <adrian@FreeBSD.org>
Mon, 9 Nov 2015 15:59:42 +0000 (15:59 +0000)
Right now the only way to force a cold reset is:

* The HAL itself detects it's needed, or
* The sysctl, setting all resets to be cold.

Trouble is, cold resets take quite a bit longer than warm resets.

However, there are situations where a cold reset would be nice.
Specifically, after a stuck beacon, BB/MAC hang, stuck calibration results,
etc.

The vendor HAL has a separate method to set the reset reason (which is
how HAL_RESET_BBPANIC gets set) which informs the HAL during the reset path
why it occured.  This is almost but not quite the same; I may eventually
unify both approaches in the future.

This commit just extends HAL_RESET_TYPE to include both status (eg BBPANIC)
and type (eg do COLD.)  None of the HAL code uses it yet though;  that'll
come later.

It also is a big no-op in each HAL - I need to go teach each of the HALs
about cold/warm reset through this path.

17 files changed:
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.h
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.c
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.h
sys/dev/ath/ath_hal/ah.h
sys/dev/ath/ath_hal/ar5210/ar5210.h
sys/dev/ath/ath_hal/ar5210/ar5210_reset.c
sys/dev/ath/ath_hal/ar5211/ar5211.h
sys/dev/ath/ath_hal/ar5211/ar5211_reset.c
sys/dev/ath/ath_hal/ar5212/ar5212.h
sys/dev/ath/ath_hal/ar5212/ar5212_reset.c
sys/dev/ath/ath_hal/ar5312/ar5312.h
sys/dev/ath/ath_hal/ar5312/ar5312_reset.c
sys/dev/ath/ath_hal/ar5416/ar5416.h
sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
sys/dev/ath/if_ath.c
sys/dev/ath/if_athvar.h

index 6118b8292293b13bf8d7c87dd92f5c6dd4d559d4..0f817f690db621eadb1d91a3f424947641fbaa54 100644 (file)
@@ -313,6 +313,7 @@ ar9300_attach_freebsd_ops(struct ath_hal *ah)
 HAL_BOOL
 ar9300_reset_freebsd(struct ath_hal *ah, HAL_OPMODE opmode,
     struct ieee80211_channel *chan, HAL_BOOL bChannelChange,
+    HAL_RESET_TYPE resetType,
     HAL_STATUS *status)
 {
        HAL_BOOL r;
index 524c3f3fce5d4d3fdf992e5465de26d4f6e6d333..3c77e72d945e9cb9fcdb4eb7ce95a3fca6dc555d 100644 (file)
@@ -4,7 +4,7 @@
 extern void ar9300_attach_freebsd_ops(struct ath_hal *ah);
 extern HAL_BOOL ar9300_reset_freebsd(struct ath_hal *ah, HAL_OPMODE opmode,
            struct ieee80211_channel *chan, HAL_BOOL bChannelChange,
-           HAL_STATUS *status);
+           HAL_RESET_TYPE resetType, HAL_STATUS *status);
 extern void ar9300_config_pcie_freebsd(struct ath_hal *, HAL_BOOL, HAL_BOOL);
 extern HAL_STATUS ar9300_eeprom_get_freebsd(struct ath_hal *, int param,
            void *val);
index 8cc6e764664b47ca2d0bc12bc738013458074d78..7fe4374a3456b31b2f19b25e746743073e1bd6c8 100644 (file)
@@ -765,6 +765,7 @@ ar9300_Stub_ProcRxDesc(struct ath_hal *ah, struct ath_desc *desc0,
 HAL_BOOL
 ar9300_Stub_Reset(struct ath_hal *ah, HAL_OPMODE opmode,
                struct ieee80211_channel *chan, HAL_BOOL bChannelChange,
+               HAL_RESET_TYPE resetType,
                HAL_STATUS *status)
 {
 
index e8d7225790c6e0bd90b20b28c3e108445084e70a..82397f9fcb1a8c388c0384f0028813a465e472ac 100644 (file)
@@ -128,6 +128,7 @@ extern      HAL_STATUS ar9300_Stub_ProcRxDesc(struct ath_hal *ah, struct ath_desc *,
 
 extern HAL_BOOL ar9300_Stub_Reset(struct ath_hal *ah, HAL_OPMODE opmode,
                struct ieee80211_channel *chan, HAL_BOOL bChannelChange,
+               HAL_RESET_TYPE resetType,
                HAL_STATUS *status);
 extern HAL_BOOL ar9300_Stub_SetChannel(struct ath_hal *,
                const struct ieee80211_channel *);
index facfceb1b110695ccbb2a0f0a23157ae691bb52e..76f37d6af51dd9f9bbd0b02673b639ac1ae18237 100644 (file)
@@ -753,6 +753,12 @@ typedef enum {
        HAL_M_MONITOR   = 8                     /* Monitor mode */
 } HAL_OPMODE;
 
+typedef enum {
+       HAL_RESET_NORMAL        = 0,            /* Do normal reset */
+       HAL_RESET_BBPANIC       = 1,            /* Reset because of BB panic */
+       HAL_RESET_FORCE_COLD    = 2,            /* Force full reset */
+} HAL_RESET_TYPE;
+
 typedef struct {
        uint8_t         kv_type;                /* one of HAL_CIPHER */
        uint8_t         kv_apsd;                /* Mask for APSD enabled ACs */
@@ -1088,11 +1094,6 @@ typedef enum {
        HAL_GEN_TIMER_TSF_ANY
 } HAL_GEN_TIMER_DOMAIN;
 
-typedef enum {
-       HAL_RESET_NONE = 0x0,
-       HAL_RESET_BBPANIC = 0x1,
-} HAL_RESET_TYPE;
-
 /*
  * BT Co-existence definitions
  */
@@ -1354,7 +1355,9 @@ struct ath_hal {
        /* Reset functions */
        HAL_BOOL  __ahdecl(*ah_reset)(struct ath_hal *, HAL_OPMODE,
                                struct ieee80211_channel *,
-                               HAL_BOOL bChannelChange, HAL_STATUS *status);
+                               HAL_BOOL bChannelChange,
+                               HAL_RESET_TYPE resetType,
+                               HAL_STATUS *status);
        HAL_BOOL  __ahdecl(*ah_phyDisable)(struct ath_hal *);
        HAL_BOOL  __ahdecl(*ah_disable)(struct ath_hal *);
        void      __ahdecl(*ah_configPCIE)(struct ath_hal *, HAL_BOOL restore,
index 3e372f7616d07132a1f570eaa82aa6764c0d4bfc..71d78b5653555e0e8e45458b7a21e6de01e31c55 100644 (file)
@@ -129,7 +129,8 @@ struct ath_hal;
 
 extern void ar5210Detach(struct ath_hal *ah);
 extern HAL_BOOL ar5210Reset(struct ath_hal *, HAL_OPMODE,
-               struct ieee80211_channel *, HAL_BOOL bChannelChange, HAL_STATUS *);
+               struct ieee80211_channel *, HAL_BOOL bChannelChange,
+               HAL_RESET_TYPE, HAL_STATUS *);
 extern void ar5210SetPCUConfig(struct ath_hal *);
 extern HAL_BOOL ar5210PhyDisable(struct ath_hal *);
 extern HAL_BOOL ar5210Disable(struct ath_hal *);
index 1dba729463ef806c4201959f5abb33f203b754a3..6029bff8b2813e033fdfc4f3deb7e68aeb26ff7d 100644 (file)
@@ -69,6 +69,7 @@ static void ar5210SetOperatingMode(struct ath_hal *, int opmode);
 HAL_BOOL
 ar5210Reset(struct ath_hal *ah, HAL_OPMODE opmode,
        struct ieee80211_channel *chan, HAL_BOOL bChannelChange,
+       HAL_RESET_TYPE resetType,
        HAL_STATUS *status)
 {
 #define        N(a)    (sizeof (a) /sizeof (a[0]))
index 6f04624161adcfe2c8bb7e2c089eda93dcf421ec..cdc33e175a3fcff0156ca0a92ae3aa0b7da97a2a 100644 (file)
@@ -147,6 +147,7 @@ extern      void ar5211Detach(struct ath_hal *);
 
 extern HAL_BOOL ar5211Reset(struct ath_hal *, HAL_OPMODE,
                struct ieee80211_channel *, HAL_BOOL bChannelChange,
+               HAL_RESET_TYPE,
                HAL_STATUS *);
 extern HAL_BOOL ar5211PhyDisable(struct ath_hal *);
 extern HAL_BOOL ar5211Disable(struct ath_hal *);
index 01e3967832f2fd68f1ea4b456468e29c23b1c659..14c20873d4ed1cace8ee129584f3b5ada0d9c95d 100644 (file)
@@ -154,6 +154,7 @@ static void ar5211SetOperatingMode(struct ath_hal *, int opmode);
 HAL_BOOL
 ar5211Reset(struct ath_hal *ah, HAL_OPMODE opmode,
        struct ieee80211_channel *chan, HAL_BOOL bChannelChange,
+       HAL_RESET_TYPE resetType,
        HAL_STATUS *status)
 {
 uint32_t softLedCfg, softLedState;
index 938a68c2b1b8336033aa6a444a0486d8b77b55a8..bab061dbb39b346740f13875ba0ebfa36914be43 100644 (file)
@@ -553,7 +553,7 @@ extern      HAL_STATUS ar5212ProcRxDesc(struct ath_hal *ah, struct ath_desc *,
 
 extern HAL_BOOL ar5212Reset(struct ath_hal *ah, HAL_OPMODE opmode,
                struct ieee80211_channel *chan, HAL_BOOL bChannelChange,
-               HAL_STATUS *status);
+               HAL_RESET_TYPE, HAL_STATUS *status);
 extern HAL_BOOL ar5212SetChannel(struct ath_hal *,
                const struct ieee80211_channel *);
 extern void ar5212SetOperatingMode(struct ath_hal *ah, int opmode);
index fd3b473a148a91740e86a15a9ffd95d343a5d086..34c93eb77881d0457f8e1d389329ebc465ba9042 100644 (file)
@@ -116,7 +116,9 @@ write_common(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
 HAL_BOOL
 ar5212Reset(struct ath_hal *ah, HAL_OPMODE opmode,
        struct ieee80211_channel *chan,
-       HAL_BOOL bChannelChange, HAL_STATUS *status)
+       HAL_BOOL bChannelChange,
+       HAL_RESET_TYPE, resetType,
+       HAL_STATUS *status)
 {
 #define        N(a)    (sizeof (a) / sizeof (a[0]))
 #define        FAIL(_code)     do { ecode = _code; goto bad; } while (0)
index 0fb9b750c3e9906792effd65f575fad3177d2e79..d7293562033a8085d9ecae7f02b03eda5e000791 100644 (file)
@@ -62,8 +62,10 @@ extern  void ar5312SetupClock(struct ath_hal *ah, HAL_OPMODE opmode);
 extern  void ar5312RestoreClock(struct ath_hal *ah, HAL_OPMODE opmode);
 extern  void ar5312DumpState(struct ath_hal *ah);
 extern  HAL_BOOL ar5312Reset(struct ath_hal *ah, HAL_OPMODE opmode,
-              struct ieee80211_channel *chan,
-             HAL_BOOL bChannelChange, HAL_STATUS *status);
+           struct ieee80211_channel *chan,
+             HAL_BOOL bChannelChange,
+             HAL_RESET_TYPE resetType,
+             HAL_STATUS *status);
 extern  HAL_BOOL ar5312ChipReset(struct ath_hal *ah,
              struct ieee80211_channel *chan);
 extern  HAL_BOOL ar5312SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode,
index fdba35d84d7a920c8f6e4eea0dd66532c0c863b4..1f1f6cfe3eb076250af6a85f5606b01ff6edd081 100644 (file)
@@ -88,7 +88,9 @@ write_common(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
 HAL_BOOL
 ar5312Reset(struct ath_hal *ah, HAL_OPMODE opmode,
        struct ieee80211_channel *chan,
-       HAL_BOOL bChannelChange, HAL_STATUS *status)
+       HAL_BOOL bChannelChange,
+       HAL_RESET_TYPE resetType,
+       HAL_STATUS *status)
 {
 #define        N(a)    (sizeof (a) / sizeof (a[0]))
 #define        FAIL(_code)     do { ecode = _code; goto bad; } while (0)
index a631aadda709c12ddf0cae4e2cd6f7d2f3a270af..31c11136faa17638f18c01705d1388edb6c1a667 100644 (file)
@@ -193,7 +193,7 @@ extern      void ar5416RxMonitor(struct ath_hal *, const HAL_NODE_STATS *,
                             const struct ieee80211_channel *);
 extern void ar5416AniPoll(struct ath_hal *, const struct ieee80211_channel *);
 extern void ar5416AniReset(struct ath_hal *, const struct ieee80211_channel *,
-               HAL_OPMODE, int);
+               HAL_OPMODE, HAL_RESET_TYPE, int);
 
 extern void ar5416SetBeaconTimers(struct ath_hal *, const HAL_BEACON_TIMERS *);
 extern void ar5416BeaconInit(struct ath_hal *ah,
@@ -303,7 +303,9 @@ extern      HAL_STATUS ar5416ProcRxDesc(struct ath_hal *ah, struct ath_desc *,
 
 extern HAL_BOOL ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
                struct ieee80211_channel *chan,
-               HAL_BOOL bChannelChange, HAL_STATUS *status);
+               HAL_BOOL bChannelChange,
+               HAL_RESET_TYPE,
+               HAL_STATUS *status);
 extern HAL_BOOL ar5416PhyDisable(struct ath_hal *ah);
 extern HAL_RFGAIN ar5416GetRfgain(struct ath_hal *ah);
 extern HAL_BOOL ar5416Disable(struct ath_hal *ah);
index baf0cccb923bb4e149027c541863478a67edd908..6abb7b4f85499351de05083c218680f1455a6711 100644 (file)
@@ -75,7 +75,9 @@ static void ar5416SetIFSTiming(struct ath_hal *ah,
 HAL_BOOL
 ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
        struct ieee80211_channel *chan,
-       HAL_BOOL bChannelChange, HAL_STATUS *status)
+       HAL_BOOL bChannelChange,
+       HAL_RESET_TYPE resetType,
+       HAL_STATUS *status)
 {
 #define        N(a)    (sizeof (a) / sizeof (a[0]))
 #define        FAIL(_code)     do { ecode = _code; goto bad; } while (0)
index 26b1060b5a18b8c34806426a2c48974ed2092a6a..c05db5c3d525b14b7c627c7acb263944e0dd09c2 100644 (file)
@@ -1916,7 +1916,7 @@ ath_resume(struct ath_softc *sc)
 
        ath_hal_reset(ah, sc->sc_opmode,
            sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan,
-           AH_FALSE, &status);
+           AH_FALSE, HAL_RESET_NORMAL, &status);
        ath_reset_keycache(sc);
 
        ATH_RX_LOCK(sc);
@@ -2449,7 +2449,7 @@ ath_init(struct ath_softc *sc)
            sc->sc_cur_rxchainmask);
 
        if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE,
-           &status)) {
+           HAL_RESET_NORMAL, &status)) {
                device_printf(sc->sc_dev,
                    "unable to reset hardware; hal status %u\n", status);
                return (ENODEV);
@@ -2823,7 +2823,8 @@ ath_reset(struct ath_softc *sc, ATH_RESET_TYPE reset_type)
        ath_update_chainmasks(sc, ic->ic_curchan);
        ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
            sc->sc_cur_rxchainmask);
-       if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, &status))
+       if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE,
+           HAL_RESET_NORMAL, &status))
                device_printf(sc->sc_dev,
                    "%s: unable to reset hardware; hal status %u\n",
                    __func__, status);
@@ -5423,7 +5424,8 @@ ath_chan_set(struct ath_softc *sc, struct ieee80211_channel *chan)
                ath_update_chainmasks(sc, chan);
                ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
                    sc->sc_cur_rxchainmask);
-               if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, &status)) {
+               if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE,
+                   HAL_RESET_NORMAL, &status)) {
                        device_printf(sc->sc_dev, "%s: unable to reset "
                            "channel %u (%u MHz, flags 0x%x), hal status %u\n",
                            __func__, ieee80211_chan2ieee(ic, chan),
index e3d414b3fd03117dde21d47ba244d439d217e788..30763a28d3effed633ce76e356a20dd483defc4f 100644 (file)
@@ -1035,8 +1035,9 @@ void      ath_intr(void *);
  */
 #define        ath_hal_detach(_ah) \
        ((*(_ah)->ah_detach)((_ah)))
-#define        ath_hal_reset(_ah, _opmode, _chan, _fullreset, _pstatus) \
-       ((*(_ah)->ah_reset)((_ah), (_opmode), (_chan), (_fullreset), (_pstatus)))
+#define        ath_hal_reset(_ah, _opmode, _chan, _fullreset, _resettype, _pstatus) \
+       ((*(_ah)->ah_reset)((_ah), (_opmode), (_chan), (_fullreset), \
+           (_resettype), (_pstatus)))
 #define        ath_hal_macversion(_ah) \
        (((_ah)->ah_macVersion << 4) | ((_ah)->ah_macRev))
 #define        ath_hal_getratetable(_ah, _mode) \