iwlwifi: mvm: capture the FCS in monitor mode
authorJohannes Berg <johannes.berg@intel.com>
Mon, 21 Oct 2013 10:37:53 +0000 (12:37 +0200)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Tue, 29 Oct 2013 13:52:25 +0000 (14:52 +0100)
This can be useful when using the device as a sniffer.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c
drivers/net/wireless/iwlwifi/mvm/rx.c

index ab5a7ac90dcd68948882cc245cd8df04e62df37c..f41f9b079831cfe7722b4d0c23203640993e7249 100644 (file)
@@ -719,7 +719,9 @@ static int iwl_mvm_mac_ctxt_cmd_listener(struct iwl_mvm *mvm,
        cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_PROMISC |
                                       MAC_FILTER_IN_CONTROL_AND_MGMT |
                                       MAC_FILTER_IN_BEACON |
-                                      MAC_FILTER_IN_PROBE_REQUEST);
+                                      MAC_FILTER_IN_PROBE_REQUEST |
+                                      MAC_FILTER_IN_CRC32);
+       mvm->hw->flags |= IEEE80211_HW_RX_INCLUDES_FCS;
 
        return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
 }
@@ -1122,6 +1124,10 @@ int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
        }
 
        mvmvif->uploaded = false;
+
+       if (vif->type == NL80211_IFTYPE_MONITOR)
+               mvm->hw->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
+
        return 0;
 }
 
index a4af5019a4960bc1afe1e0b9a5c5296381d4f590..3a1f3982109d1dbc02bccba42588545e000b8271 100644 (file)
@@ -300,10 +300,14 @@ int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
                return 0;
        }
 
+       /*
+        * Keep packets with CRC errors (and with overrun) for monitor mode
+        * (otherwise the firmware discards them) but mark them as bad.
+        */
        if (!(rx_pkt_status & RX_MPDU_RES_STATUS_CRC_OK) ||
            !(rx_pkt_status & RX_MPDU_RES_STATUS_OVERRUN_OK)) {
                IWL_DEBUG_RX(mvm, "Bad CRC or FIFO: 0x%08X.\n", rx_pkt_status);
-               return 0;
+               rx_status.flag |= RX_FLAG_FAILED_FCS_CRC;
        }
 
        /* This will be used in several places later */