Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp175442lqh; Thu, 30 May 2024 19:13:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1dlSlMx7sOtIJV02CeOWt5C+PZVwAbEo02iRKZeGKiuB8djtcxn08O47cC1AJFF+bYbGvTPKKDMICs/upoXxBaTN4GFHFatFllkNJWg== X-Google-Smtp-Source: AGHT+IFp9tpW+EpMYnOQ+5qFe2XY3ZtriWlpUiXtaQT1KNgHYz6b2vKOqykbGHXediqGX+zqdC9y X-Received: by 2002:a05:6a20:2445:b0:1af:cefe:9741 with SMTP id adf61e73a8af0-1b26f12184cmr1039549637.17.1717121620353; Thu, 30 May 2024 19:13:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717121620; cv=pass; d=google.com; s=arc-20160816; b=yjBRmzHsu0Ekcdfju3YwBLE4wga6vKgvJV6K85RWQmWdwBlCV4vrq6JO16lhPIlaUG VrcZW0MG1qRdeY8pEPaiXvB3FXDh62IR5cF9wTLH+GBz+Gu1nasLd30IY8IShTTXz8AK HCBmeHGTS5mZhLsSG46ZMnA3L6nhXMscbyQrmluhlOdxZwFiSgFuqAwfU+HXZr8ICYiL 1zqeM4egVTm9QzQdrn2GYi7FB+kWZqlqHymEI8baGEaNUEAHb2Bw3dg493VLwSgUa08z B91jp5q5O7XBQqRmCuOKBxYEtTADMP1lyUj01YZuffu/se8NMEWaE4h1v+iS9VfaWVex UXeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=PMQuTx0ADMO67gqLZK+0ucpPSSwMWOw5jqxYdmmkpgA=; fh=j480mrNlK527R2LSjAa5EczedEomDzgwrIPbXwRGWTc=; b=NyGRjA2E8GyZgP1G4mSYHahNn3MUOHi+GheBj9OXkyX4Cg87kSGwyke2XUKer+/2Ni ZtGhihJMHrBPqQXT2tLgxf6NDoWtJlk7Cqf0JBp6T17LHiA3XGdwCRLczZQ8Bait2BFZ ustRMkzVvYxrgRe0ceO1NnddxM6nEQHwB+zpbtbiOTdmiVBjxyXQLiKQiieTj3bSDQyr EpO0O1EnJLPhio6oOyMgaZMJonwIJekfM/71hQSwv0Kbg9mRUcC1rKE6nkLzOQ1DHA+8 gF27imp1SteDfcp0KnAVTLTc9bscOW4qeMEJrlcCtY+tsAI//sMWXRo7jnfQ5DQUOo2t PScg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GzHuYAZr; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-8331-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8331-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1a77da83csi2499256a91.186.2024.05.30.19.13.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 19:13:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8331-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GzHuYAZr; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-8331-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8331-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A82EDB22B17 for ; Fri, 31 May 2024 02:13:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29BF56BB33; Fri, 31 May 2024 02:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="GzHuYAZr" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F4BA4C7C for ; Fri, 31 May 2024 02:13:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717121612; cv=none; b=Aht33GeSioiwz1PpS0BXPdsu3gGgT8cjenoi4B7CmaHeZ09KAWkj8Vp3bIZU95xcI1riJunGhfAL1nLQ+2SoA3vKU0yA9wrJt+XK5mSKr3/wwpWTjSE+0Abbm3Ai++kulIjUzPWaWYX36wyFYgsfQBH0DxGQs7GK39BXkWFiycU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717121612; c=relaxed/simple; bh=zUYs089rtgF3Gjil9oBIbUjoQZco0707gh5NqRMlx14=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=VP6w+3hxIkAp3LVEcaJWDjLkzRduTxj1f03YroglR4fEWiX/ffiSJyk2BxWhHh2mEtOnIlyHeaxoTZehPQVkVofJ8o2HxnZNoYprvGrLIZb/U8dOQj4A6oouq67hQQrKLqK/EsitJLJLRiBvUFoCvnFwIrsiLlX7330FtGEma9k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=GzHuYAZr; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44UIY0pn031661; Fri, 31 May 2024 02:13:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=PMQuTx0ADMO67gqLZK+0uc pPSSwMWOw5jqxYdmmkpgA=; b=GzHuYAZrByEbE/eaQY51pBGkeHxg0hGo7DxkJe n08iN43zd/J7hylMssmZ6bB++7t05rrIknMNMGJzF8uTmZx8zBHhO5WxUEvlKf1R lqnGKYNt6mWpe9wRKL+EwS8NQ1jZrbzQ3x03jzEYUv10SjqsF3TJiEHMmIPy6vX+ miYjsEv5n5wo2bCy4CgKfpVTZzAFsR252O+1QZSd296KYK/8ZvhYSvdGtdoD/+/n 0UxO6uxkFk3NP0wMBCWCOcrjb2i2KulnDgRxL/aTeT1xXevLn9aEdZKiCwEkpm1F Ga3VAFqSKCIhLELaROQBz0VeJCwXgaUjpYCwf7SkrRfjTkUQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3yba2n5j9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 May 2024 02:13:24 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44V2DNMs006614 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 May 2024 02:13:23 GMT Received: from bqiang-SFF.qca.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 30 May 2024 19:13:21 -0700 From: Baochen Qiang To: CC: , Subject: [PATCH] wifi: ath11k: fix wrong handling of CCMP256 and GCMP ciphers Date: Fri, 31 May 2024 10:12:28 +0800 Message-ID: <20240531021228.2846-1-quic_bqiang@quicinc.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 1xexL9PEDSxFu6k4PY4IBXSRqx9iBUYD X-Proofpoint-ORIG-GUID: 1xexL9PEDSxFu6k4PY4IBXSRqx9iBUYD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-30_21,2024-05-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 adultscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2405310016 Currently for CCMP256, GCMP128 and GCMP256 ciphers, in ath11k_install_key() IEEE80211_KEY_FLAG_GENERATE_IV_MGMT is not set. And in ath11k_mac_mgmt_tx_wmi() a length of IEEE80211_CCMP_MIC_LEN is reserved for all ciphers. This results in unexpected management frame drop in case either of above 3 ciphers is used. The reason is, without IEEE80211_KEY_FLAG_GENERATE_IV_MGMT set, mac80211 will not generate CCMP/GCMP headers in frame for ath11k. Also MIC length reserved is wrong. Such frame is dropped later by hardware: ath11k_pci 0000:5a:00.0: mac tx mgmt frame, buf id 0 ath11k_pci 0000:5a:00.0: mgmt tx compl ev pdev_id 1, desc_id 0, status 1 From user point of view, we have observed very low throughput due to this issue: action frames are all dropped so ADDBA response from DUT never reaches AP. AP can not use aggregation thus throughput is low. Fix this by setting IEEE80211_KEY_FLAG_GENERATE_IV_MGMT flag and by reserving proper MIC length for those ciphers. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Baochen Qiang --- drivers/net/wireless/ath/ath11k/dp_rx.c | 3 +-- drivers/net/wireless/ath/ath11k/dp_rx.h | 3 +++ drivers/net/wireless/ath/ath11k/mac.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 198fb359a688..86485580dd89 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -1877,8 +1877,7 @@ static void ath11k_dp_rx_h_csum_offload(struct ath11k *ar, struct sk_buff *msdu) CHECKSUM_NONE : CHECKSUM_UNNECESSARY; } -static int ath11k_dp_rx_crypto_mic_len(struct ath11k *ar, - enum hal_encrypt_type enctype) +int ath11k_dp_rx_crypto_mic_len(struct ath11k *ar, enum hal_encrypt_type enctype) { switch (enctype) { case HAL_ENCRYPT_TYPE_OPEN: diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.h b/drivers/net/wireless/ath/ath11k/dp_rx.h index 623da3bf9dc8..c322e30caa96 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.h +++ b/drivers/net/wireless/ath/ath11k/dp_rx.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause-Clear */ /* * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef ATH11K_DP_RX_H #define ATH11K_DP_RX_H @@ -95,4 +96,6 @@ int ath11k_peer_rx_frag_setup(struct ath11k *ar, const u8 *peer_mac, int vdev_id int ath11k_dp_rx_pktlog_start(struct ath11k_base *ab); int ath11k_dp_rx_pktlog_stop(struct ath11k_base *ab, bool stop_timer); +int ath11k_dp_rx_crypto_mic_len(struct ath11k *ar, enum hal_encrypt_type enctype); + #endif /* ATH11K_DP_RX_H */ diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index a1800c75d32b..5d6b01d942df 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -4229,6 +4229,7 @@ static int ath11k_install_key(struct ath11k_vif *arvif, switch (key->cipher) { case WLAN_CIPHER_SUITE_CCMP: + case WLAN_CIPHER_SUITE_CCMP_256: arg.key_cipher = WMI_CIPHER_AES_CCM; /* TODO: Re-check if flag is valid */ key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV_MGMT; @@ -4238,12 +4239,10 @@ static int ath11k_install_key(struct ath11k_vif *arvif, arg.key_txmic_len = 8; arg.key_rxmic_len = 8; break; - case WLAN_CIPHER_SUITE_CCMP_256: - arg.key_cipher = WMI_CIPHER_AES_CCM; - break; case WLAN_CIPHER_SUITE_GCMP: case WLAN_CIPHER_SUITE_GCMP_256: arg.key_cipher = WMI_CIPHER_AES_GCM; + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV_MGMT; break; default: ath11k_warn(ar->ab, "cipher %d is not supported\n", key->cipher); @@ -5903,7 +5902,10 @@ static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif, { struct ath11k_base *ab = ar->ab; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(skb); struct ieee80211_tx_info *info; + enum hal_encrypt_type enctype; + unsigned int mic_len; dma_addr_t paddr; int buf_id; int ret; @@ -5927,7 +5929,10 @@ static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif, ieee80211_is_deauth(hdr->frame_control) || ieee80211_is_disassoc(hdr->frame_control)) && ieee80211_has_protected(hdr->frame_control)) { - skb_put(skb, IEEE80211_CCMP_MIC_LEN); + WARN_ON(!(skb_cb->flags & ATH11K_SKB_CIPHER_SET)); + enctype = ath11k_dp_tx_get_encrypt_type(skb_cb->cipher); + mic_len = ath11k_dp_rx_crypto_mic_len(ar, enctype); + skb_put(skb, mic_len); } } base-commit: 6e7a5c6d5e38b93f9cc3289d66a597b9a4ca0403 -- 2.25.1