iwlwifi: mvm: Support TKIP on gen2 data path
authorDavid Spinadel <david.spinadel@intel.com>
Tue, 7 Nov 2017 09:59:57 +0000 (11:59 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 28 Sep 2018 05:57:24 +0000 (08:57 +0300)
Make the adjustments for gen2 TX and RX of TKIP packets.  Strip MIC on
RX.  Don't add IV space and keep the MIC space zeroed on TX.

Devices that support gen2 data path support TKIP only in station mode.
In all other modes, fall back to SW encryption. Do this early in the
set_key() callback so that the key flags would not be incorrectly set.

Signed-off-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c

index 134bb9f..b55a2e4 100644 (file)
@@ -3151,8 +3151,15 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
 
        switch (key->cipher) {
        case WLAN_CIPHER_SUITE_TKIP:
-               key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
-               key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE;
+               if (!mvm->trans->cfg->gen2) {
+                       key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
+                       key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE;
+               } else if (vif->type == NL80211_IFTYPE_STATION) {
+                       key->flags |= IEEE80211_KEY_FLAG_PUT_MIC_SPACE;
+               } else {
+                       IWL_DEBUG_MAC80211(mvm, "Use SW encryption for TKIP\n");
+                       return -EOPNOTSUPP;
+               }
                break;
        case WLAN_CIPHER_SUITE_CCMP:
        case WLAN_CIPHER_SUITE_GCMP:
index 89b4b88..894dd63 100644 (file)
@@ -283,6 +283,10 @@ static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
                    !(status & IWL_RX_MPDU_RES_STATUS_TTAK_OK))
                        return 0;
 
+               if (mvm->trans->cfg->gen2 &&
+                   !(status & RX_MPDU_RES_STATUS_MIC_OK))
+                       stats->flag |= RX_FLAG_MMIC_ERROR;
+
                *crypt_len = IEEE80211_TKIP_IV_LEN;
                /* fall through if TTAK OK */
        case IWL_RX_MPDU_STATUS_SEC_WEP:
@@ -294,8 +298,11 @@ static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
                                IWL_RX_MPDU_STATUS_SEC_WEP)
                        *crypt_len = IEEE80211_WEP_IV_LEN;
 
-               if (pkt_flags & FH_RSCSR_RADA_EN)
+               if (pkt_flags & FH_RSCSR_RADA_EN) {
                        stats->flag |= RX_FLAG_ICV_STRIPPED;
+                       if (mvm->trans->cfg->gen2)
+                               stats->flag |= RX_FLAG_MMIC_STRIPPED;
+               }
 
                return 0;
        case IWL_RX_MPDU_STATUS_SEC_EXT_ENC: