iwlwifi: dbg: group trigger condition to helper function
authorSara Sharon <sara.sharon@intel.com>
Tue, 12 Jun 2018 07:41:35 +0000 (10:41 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Sat, 6 Oct 2018 07:25:44 +0000 (10:25 +0300)
The triplet of get trigger, is trigger enabled and is trigger stopped
repeats itself.  Group them in a function to avoid code duplication.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/dbg.h
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/mvm/rx.c
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
drivers/net/wireless/intel/iwlwifi/mvm/utils.c

index e1e8a1a03c68f0db49ce147bac81091a7ce2f837..5b087fc4f380c64820a5d343e071b117a4a5d066 100644 (file)
@@ -188,6 +188,30 @@ iwl_fw_dbg_trigger_check_stop(struct iwl_fw_runtime *fwrt,
        return iwl_fw_dbg_trigger_stop_conf_match(fwrt, trig);
 }
 
+static inline struct iwl_fw_dbg_trigger_tlv*
+_iwl_fw_dbg_trigger_on(struct iwl_fw_runtime *fwrt,
+                      struct wireless_dev *wdev,
+                      const enum iwl_fw_dbg_trigger id)
+{
+       struct iwl_fw_dbg_trigger_tlv *trig;
+
+       if (!iwl_fw_dbg_trigger_enabled(fwrt->fw, id))
+               return NULL;
+
+       trig = _iwl_fw_dbg_get_trigger(fwrt->fw, id);
+
+       if (!iwl_fw_dbg_trigger_check_stop(fwrt, wdev, trig))
+               return NULL;
+
+       return trig;
+}
+
+#define iwl_fw_dbg_trigger_on(fwrt, wdev, id) ({               \
+       BUILD_BUG_ON(!__builtin_constant_p(id));                \
+       BUILD_BUG_ON((id) >= FW_DBG_TRIGGER_MAX);               \
+       _iwl_fw_dbg_trigger_on((fwrt), (wdev), (id));           \
+})
+
 static inline void
 _iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime *fwrt,
                                struct wireless_dev *wdev,
index 781f30356720a4fa599a3087fecb4251e9a5d132..6486cfb33f403d478680aca1ae489a843e81e24e 100644 (file)
@@ -1487,12 +1487,11 @@ static void iwl_mvm_beacon_loss_iterator(void *_data, u8 *mac,
             IWL_MVM_MISSED_BEACONS_THRESHOLD)
                ieee80211_beacon_loss(vif);
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw,
-                                       FW_DBG_TRIGGER_MISSED_BEACONS))
+       trigger = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
+                                       FW_DBG_TRIGGER_MISSED_BEACONS);
+       if (!trigger)
                return;
 
-       trigger = iwl_fw_dbg_get_trigger(mvm->fw,
-                                        FW_DBG_TRIGGER_MISSED_BEACONS);
        bcon_trig = (void *)trigger->data;
        stop_trig_missed_bcon = le32_to_cpu(bcon_trig->stop_consec_missed_bcon);
        stop_trig_missed_bcon_since_rx =
@@ -1500,11 +1499,6 @@ static void iwl_mvm_beacon_loss_iterator(void *_data, u8 *mac,
 
        /* TODO: implement start trigger */
 
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(vif),
-                                          trigger))
-               return;
-
        if (rx_missed_bcon_since_rx >= stop_trig_missed_bcon_since_rx ||
            rx_missed_bcon >= stop_trig_missed_bcon)
                iwl_fw_dbg_collect_trig(&mvm->fwrt, trigger, NULL);
index c78d017749d3092a7f0873b1606dcf3f2625989a..1fadcf36d1f232529b6fa8849b4d479841a14ecd 100644 (file)
@@ -857,16 +857,13 @@ iwl_mvm_ampdu_check_trigger(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
        struct iwl_fw_dbg_trigger_tlv *trig;
        struct iwl_fw_dbg_trigger_ba *ba_trig;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_BA))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
+                                    FW_DBG_TRIGGER_BA);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_BA);
        ba_trig = (void *)trig->data;
 
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(vif), trig))
-               return;
-
        switch (action) {
        case IEEE80211_AMPDU_TX_OPERATIONAL: {
                struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
@@ -2802,14 +2799,12 @@ iwl_mvm_tdls_check_trigger(struct iwl_mvm *mvm,
        struct iwl_fw_dbg_trigger_tlv *trig;
        struct iwl_fw_dbg_trigger_tdls *tdls_trig;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_TDLS))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
+                                    FW_DBG_TRIGGER_TDLS);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_TDLS);
        tdls_trig = (void *)trig->data;
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(vif), trig))
-               return;
 
        if (!(tdls_trig->action_bitmap & BIT(action)))
                return;
@@ -4491,14 +4486,12 @@ static void iwl_mvm_event_mlme_callback(struct iwl_mvm *mvm,
        struct iwl_fw_dbg_trigger_tlv *trig;
        struct iwl_fw_dbg_trigger_mlme *trig_mlme;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_MLME))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
+                                    FW_DBG_TRIGGER_MLME);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_MLME);
        trig_mlme = (void *)trig->data;
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(vif), trig))
-               return;
 
        if (event->u.mlme.data == ASSOC_EVENT) {
                if (event->u.mlme.status == MLME_DENIED)
@@ -4533,14 +4526,12 @@ static void iwl_mvm_event_bar_rx_callback(struct iwl_mvm *mvm,
        struct iwl_fw_dbg_trigger_tlv *trig;
        struct iwl_fw_dbg_trigger_ba *ba_trig;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_BA))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
+                                    FW_DBG_TRIGGER_BA);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_BA);
        ba_trig = (void *)trig->data;
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(vif), trig))
-               return;
 
        if (!(le16_to_cpu(ba_trig->rx_bar) & BIT(event->u.ba.tid)))
                return;
index 5f2f599a7ccda9ecc5d521a6e44dc6a5b1566c86..2f611bf83d5613433d514522e916b54667f69957 100644 (file)
@@ -953,15 +953,13 @@ static inline void iwl_mvm_rx_check_trigger(struct iwl_mvm *mvm,
        struct iwl_fw_dbg_trigger_cmd *cmds_trig;
        int i;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_FW_NOTIF))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, NULL,
+                                    FW_DBG_TRIGGER_FW_NOTIF);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_FW_NOTIF);
        cmds_trig = (void *)trig->data;
 
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt, NULL, trig))
-               return;
-
        for (i = 0; i < ARRAY_SIZE(cmds_trig->cmds); i++) {
                /* don't collect on CMD 0 */
                if (!cmds_trig->cmds[i].cmd_id)
index a050220da6780cb29f84f4f96e02b38a5e091fd1..ef624833cf1b7bdda6c9bcffed29cc6d0afb3cb6 100644 (file)
@@ -433,13 +433,14 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
                struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
                struct ieee80211_vif *tx_blocked_vif =
                        rcu_dereference(mvm->csa_tx_blocked_vif);
+               struct iwl_fw_dbg_trigger_tlv *trig;
+               struct ieee80211_vif *vif = mvmsta->vif;
 
                /* We have tx blocked stations (with CS bit). If we heard
                 * frames from a blocked station on a new channel we can
                 * TX to it again.
                 */
-               if (unlikely(tx_blocked_vif) &&
-                   mvmsta->vif == tx_blocked_vif) {
+               if (unlikely(tx_blocked_vif) && vif == tx_blocked_vif) {
                        struct iwl_mvm_vif *mvmvif =
                                iwl_mvm_vif_from_mac80211(tx_blocked_vif);
 
@@ -450,23 +451,18 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
 
                rs_update_last_rssi(mvm, mvmsta, rx_status);
 
-               if (iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_RSSI) &&
-                   ieee80211_is_beacon(hdr->frame_control)) {
-                       struct iwl_fw_dbg_trigger_tlv *trig;
+               trig = iwl_fw_dbg_trigger_on(&mvm->fwrt,
+                                            ieee80211_vif_to_wdev(vif),
+                                            FW_DBG_TRIGGER_RSSI);
+
+               if (trig && ieee80211_is_beacon(hdr->frame_control)) {
                        struct iwl_fw_dbg_trigger_low_rssi *rssi_trig;
-                       bool trig_check;
                        s32 rssi;
 
-                       trig = iwl_fw_dbg_get_trigger(mvm->fw,
-                                                     FW_DBG_TRIGGER_RSSI);
                        rssi_trig = (void *)trig->data;
                        rssi = le32_to_cpu(rssi_trig->rssi);
 
-                       trig_check =
-                               iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                                             ieee80211_vif_to_wdev(mvmsta->vif),
-                                                             trig);
-                       if (trig_check && rx_status->signal < rssi)
+                       if (rx_status->signal < rssi)
                                iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
                                                        NULL);
                }
@@ -693,15 +689,12 @@ iwl_mvm_rx_stats_check_trigger(struct iwl_mvm *mvm, struct iwl_rx_packet *pkt)
        struct iwl_fw_dbg_trigger_stats *trig_stats;
        u32 trig_offset, trig_thold;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_STATS))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, NULL, FW_DBG_TRIGGER_STATS);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_STATS);
        trig_stats = (void *)trig->data;
 
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt, NULL, trig))
-               return;
-
        trig_offset = le32_to_cpu(trig_stats->stop_offset);
        trig_thold = le32_to_cpu(trig_stats->stop_threshold);
 
index 894dd6379b9a8da2dfb0aa05c07b1ccb71e11fdd..5f79133029daaf1abed0bc035d3310d5861051ec 100644 (file)
@@ -1424,6 +1424,8 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
                u8 baid = (u8)((le32_to_cpu(desc->reorder_data) &
                               IWL_RX_MPDU_REORDER_BAID_MASK) >>
                               IWL_RX_MPDU_REORDER_BAID_SHIFT);
+               struct iwl_fw_dbg_trigger_tlv *trig;
+               struct ieee80211_vif *vif = mvmsta->vif;
 
                if (!mvm->tcm.paused && len >= sizeof(*hdr) &&
                    !is_multicast_ether_addr(hdr->addr1) &&
@@ -1436,8 +1438,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
                 * frames from a blocked station on a new channel we can
                 * TX to it again.
                 */
-               if (unlikely(tx_blocked_vif) &&
-                   tx_blocked_vif == mvmsta->vif) {
+               if (unlikely(tx_blocked_vif) && tx_blocked_vif == vif) {
                        struct iwl_mvm_vif *mvmvif =
                                iwl_mvm_vif_from_mac80211(tx_blocked_vif);
 
@@ -1448,23 +1449,18 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
 
                rs_update_last_rssi(mvm, mvmsta, rx_status);
 
-               if (iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_RSSI) &&
-                   ieee80211_is_beacon(hdr->frame_control)) {
-                       struct iwl_fw_dbg_trigger_tlv *trig;
+               trig = iwl_fw_dbg_trigger_on(&mvm->fwrt,
+                                            ieee80211_vif_to_wdev(vif),
+                                            FW_DBG_TRIGGER_RSSI);
+
+               if (trig && ieee80211_is_beacon(hdr->frame_control)) {
                        struct iwl_fw_dbg_trigger_low_rssi *rssi_trig;
-                       bool trig_check;
                        s32 rssi;
 
-                       trig = iwl_fw_dbg_get_trigger(mvm->fw,
-                                                     FW_DBG_TRIGGER_RSSI);
                        rssi_trig = (void *)trig->data;
                        rssi = le32_to_cpu(rssi_trig->rssi);
 
-                       trig_check =
-                               iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                                             ieee80211_vif_to_wdev(mvmsta->vif),
-                                                             trig);
-                       if (trig_check && rx_status->signal < rssi)
+                       if (rx_status->signal < rssi)
                                iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
                                                        NULL);
                }
index cd91bc44259c63c549062a62bd08cc7705e2748d..e1a6f4e2225331cd93c0f6d7ff6ac2063aaaeddf 100644 (file)
@@ -254,17 +254,14 @@ static void iwl_mvm_te_check_trigger(struct iwl_mvm *mvm,
        struct iwl_fw_dbg_trigger_time_event *te_trig;
        int i;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_TIME_EVENT))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt,
+                                    ieee80211_vif_to_wdev(te_data->vif),
+                                    FW_DBG_TRIGGER_TIME_EVENT);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_TIME_EVENT);
        te_trig = (void *)trig->data;
 
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(te_data->vif),
-                                          trig))
-               return;
-
        for (i = 0; i < ARRAY_SIZE(te_trig->time_events); i++) {
                u32 trig_te_id = le32_to_cpu(te_trig->time_events[i].id);
                u32 trig_action_bitmap =
index a6877b3f80372233a69056461d0a5891bedb1d4a..99c64ea2619bd393430944a5ef0f361695616b09 100644 (file)
@@ -79,15 +79,12 @@ iwl_mvm_bar_check_trigger(struct iwl_mvm *mvm, const u8 *addr,
        struct iwl_fw_dbg_trigger_tlv *trig;
        struct iwl_fw_dbg_trigger_ba *ba_trig;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_BA))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, NULL, FW_DBG_TRIGGER_BA);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_BA);
        ba_trig = (void *)trig->data;
 
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt, NULL, trig))
-               return;
-
        if (!(le16_to_cpu(ba_trig->tx_bar) & BIT(tid)))
                return;
 
@@ -1414,15 +1411,13 @@ static void iwl_mvm_tx_status_check_trigger(struct iwl_mvm *mvm,
        struct iwl_fw_dbg_trigger_tx_status *status_trig;
        int i;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_TX_STATUS))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, NULL,
+                                    FW_DBG_TRIGGER_TX_STATUS);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_TX_STATUS);
        status_trig = (void *)trig->data;
 
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt, NULL, trig))
-               return;
-
        for (i = 0; i < ARRAY_SIZE(status_trig->statuses); i++) {
                /* don't collect on status 0 */
                if (!status_trig->statuses[i].status)
index dcacc4d11abc95f916f350131aea52e1a2aeac59..6c14d3413bdcd6489e41ee15ab8d78a9d4962b80 100644 (file)
@@ -1238,14 +1238,12 @@ void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
        struct iwl_fw_dbg_trigger_tlv *trig;
        struct iwl_fw_dbg_trigger_mlme *trig_mlme;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_MLME))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
+                                    FW_DBG_TRIGGER_MLME);
+       if (!trig)
                goto out;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_MLME);
        trig_mlme = (void *)trig->data;
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(vif), trig))
-               goto out;
 
        if (trig_mlme->stop_connection_loss &&
            --trig_mlme->stop_connection_loss)
@@ -1430,14 +1428,12 @@ void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm,
        struct iwl_fw_dbg_trigger_tlv *trig;
        struct iwl_fw_dbg_trigger_ba *ba_trig;
 
-       if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_BA))
+       trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
+                                    FW_DBG_TRIGGER_BA);
+       if (!trig)
                return;
 
-       trig = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_BA);
        ba_trig = (void *)trig->data;
-       if (!iwl_fw_dbg_trigger_check_stop(&mvm->fwrt,
-                                          ieee80211_vif_to_wdev(vif), trig))
-               return;
 
        if (!(le16_to_cpu(ba_trig->frame_timeout) & BIT(tid)))
                return;