From patchwork Wed Dec 31 10:19:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 5555311 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9A2DBBF6C3 for ; Wed, 31 Dec 2014 10:20:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6378620123 for ; Wed, 31 Dec 2014 10:20:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97B5C2011E for ; Wed, 31 Dec 2014 10:19:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751226AbaLaKTo (ORCPT ); Wed, 31 Dec 2014 05:19:44 -0500 Received: from mail-wi0-f171.google.com ([209.85.212.171]:37538 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197AbaLaKTn (ORCPT ); Wed, 31 Dec 2014 05:19:43 -0500 Received: by mail-wi0-f171.google.com with SMTP id bs8so25268898wib.16 for ; Wed, 31 Dec 2014 02:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type; bh=Zywq7/WBbAl4ZelWwA8YKqpYnoSOP+elFjUdvSFCbQU=; b=ZdeRPDmkTqy2yb40wi1pE1tfoNCjAisdd64J5K8A150GD3qoGuIS6rZhPnFFcEO82I jVQMfxdU/9zd238agpZNG4vnFzs8t5LS48n5uQ4Trr9eaXejlMjnE7G5kaNsiFmJmle5 Cjof//3mpKEpSKIjiLAGCAKDH/g2QnzQOhOXm/nX8xPcfJm0dmWd0EvoaXNFALLjdYWR xji1kwDh9PAWOBoFnSZy6w3kiNLshf/0YZbqqtuoAn4h60VGTI7GzquXOnHamniUgbqa Xog9qsCITNx9wwYG9K2wCWuh3cL3sWLSpmjPntlC8+6+QJLAsqRxSxLgrRQEIgy+g/Uv SjVA== X-Received: by 10.194.52.37 with SMTP id q5mr126342316wjo.39.1420021182081; Wed, 31 Dec 2014 02:19:42 -0800 (PST) Received: from debian64.daheim (p5B2E66FA.dip0.t-ipconnect.de. [91.46.102.250]) by mx.google.com with ESMTPSA id l9sm46544334wic.21.2014.12.31.02.19.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Dec 2014 02:19:41 -0800 (PST) Received: from localhost.daheim ([127.0.0.1] helo=debian64.localnet) by debian64.daheim with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Y6GNQ-0003gN-0M; Wed, 31 Dec 2014 11:19:40 +0100 From: Christian Lamparter To: linux-wireless@vger.kernel.org Cc: kvalo@codeaurora.org, Larry.Finger@lwfinger.net, chrischavez@gmx.us, pizza@shaftnet.org, johannes@sipsolutions.net Subject: [PATCH 3.17 1/3] mac80211: add feature flag to enable resizing of outgoing frames for encryption Date: Wed, 31 Dec 2014 11:19:39 +0100 Message-ID: <2051417.66dkbc7KnO@debian64> User-Agent: KMail/4.14.2 (Linux/3.19.0-rc1-wl+; KDE/4.14.2; x86_64; ; ) MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch "mac80211: Fix accounting of the tailroom-needed counter" reduced the overhead associated with unnecessary resizing of outgoing frames. Unfortunately this change broke the assumption that there is always enough tailroom for the MIC. This in turn caused p54* to panic when it tried to prepare outgoing frames for hardware-offloaded CCMP connections. Cc: stable@vger.kernel.org Cc: Johannes Berg Cc: Kalle Valo Bugzilla: Reported-by: Christopher Chavez Tested-by: Larry Finger Signed-off-by: Christian Lamparter --- include/net/mac80211.h | 13 ++++++++++--- net/mac80211/key.c | 9 ++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 58d719d..c04ac04 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1270,8 +1270,11 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev); * * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the * driver to indicate that it requires IV generation for this - * particular key. Setting this flag does not necessarily mean that SKBs - * will have sufficient tailroom for ICV or MIC. + * particular key. Setting this flag does not mean that SKBs will + * have sufficient tailroom for ICV or MIC. If additional tailroom + * tailroom needs to be reserved for the ICV or MIC, the driver + * should also set the hardware feature flag: + * %IEEE80211_HW_TAILROOM_CRYPTO. * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by * the driver for a TKIP key if it requires Michael MIC * generation in software. @@ -1583,6 +1586,10 @@ struct ieee80211_tx_control { * @IEEE80211_HW_MFP_CAPABLE: * Hardware supports management frame protection (MFP, IEEE 802.11w). * + * @IEEE80211_HW_TAILROOM_CRYPTO: The driver would like to have sufficient + * tailroom for ICV or MIC for outgoing frames in order to perform + * hardware encryption without any additional resizing overhead. + * * @IEEE80211_HW_SUPPORTS_UAPSD: * Hardware supports Unscheduled Automatic Power Save Delivery * (U-APSD) in managed mode. The mode is configured with @@ -1673,7 +1680,7 @@ enum ieee80211_hw_flags { IEEE80211_HW_MFP_CAPABLE = 1<<13, IEEE80211_HW_WANT_MONITOR_VIF = 1<<14, IEEE80211_HW_NO_AUTO_VIF = 1<<15, - /* free slot */ + IEEE80211_HW_TAILROOM_CRYPTO = 1<<16, IEEE80211_HW_SUPPORTS_UAPSD = 1<<17, IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, IEEE80211_HW_CONNECTION_MONITOR = 1<<19, diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 0bb7038..c3e9a9a 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -140,7 +140,8 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) if (!ret) { key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; - if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) + if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || + (key->local->hw.flags & IEEE80211_HW_TAILROOM_CRYPTO))) sdata->crypto_tx_tailroom_needed_cnt--; WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && @@ -188,7 +189,8 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) sta = key->sta; sdata = key->sdata; - if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) + if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || + (key->local->hw.flags & IEEE80211_HW_TAILROOM_CRYPTO))) increment_tailroom_need_count(sdata); ret = drv_set_key(key->local, DISABLE_KEY, sdata, @@ -884,7 +886,8 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf) if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; - if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) + if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || + (key->local->hw.flags & IEEE80211_HW_TAILROOM_CRYPTO))) increment_tailroom_need_count(key->sdata); }