From patchwork Mon Jun 1 19:38:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu CF/TW X-Patchwork-Id: 6524371 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 A2129C0433 for ; Mon, 1 Jun 2015 19:39:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B98E0203E6 for ; Mon, 1 Jun 2015 19:39:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCCF62040F for ; Mon, 1 Jun 2015 19:39:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932099AbbFATjH (ORCPT ); Mon, 1 Jun 2015 15:39:07 -0400 Received: from mail-ig0-f181.google.com ([209.85.213.181]:35488 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753032AbbFATi6 (ORCPT ); Mon, 1 Jun 2015 15:38:58 -0400 Received: by igbyr2 with SMTP id yr2so70218063igb.0 for ; Mon, 01 Jun 2015 12:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=zGMWh3pTtxJczS+0BM1/xC74dWIc+/UkJhF4T6XLEKI=; b=Q4mDQRbJvJPEufUQEsn+3LLC4p+6YMs7JESX0VG6VcV2BzwAlmKqUi2i0ZqI5qWJKH 1kvp7lQTVygMVrdCLyVeRJEf8+05ep7VgXVPv7QAvqCEfWOwPS/SETsasbEzkDAK5mSr hDMUBar7dZ2waEOOCY6Cvy2Yj4+skKF/FBKXaqsDILUZClb7xLFmnff1eShCGnm9c/h1 cUgDDkO1RIw3N55aLhNVCAhxVwArIcxZExKo2ieFoLKtAX+cmRkNBRB6DpOK7+GmplA1 YbDXbF1NFv1hizb8MZrsOdKpeJHJoDh7VmDZGS0SEQWCOBNvW/SFdcN75L0FRFjj4DCO pzfg== X-Received: by 10.107.47.224 with SMTP id v93mr893473iov.86.1433187538270; Mon, 01 Jun 2015 12:38:58 -0700 (PDT) Received: from cfvm.localdomain ([172.17.73.26]) by mx.google.com with ESMTPSA id 85sm9681555iom.25.2015.06.01.12.38.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 12:38:57 -0700 (PDT) From: David Liu To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, kvalo@qca.qualcomm.com, David Liu Subject: [PATCH] mac80211: support IEEE80211_KEY_FLAG_RESERVE_TAILROOM for CCMP and TKIP. Date: Mon, 1 Jun 2015 12:38:18 -0700 Message-Id: <1433187498-15124-1-git-send-email-cfliu.tw@gmail.com> X-Mailer: git-send-email 2.1.4 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 change reserves neccessary tailroom in CCMP and TKIP if required by drivers that sets IEEE80211_KEY_FLAG_RESERVE_TAILROOM. For example, ath10k HW engine in raw Tx/Rx encap mode requires SW reserve MIC/ICV space. Signed-off-by: David Liu --- net/mac80211/wpa.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index 9d63d93..b56f31a 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c @@ -192,7 +192,9 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) if (info->control.hw_key && !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) && - !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { + !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && + !(info->control.hw_key->flags & + IEEE80211_KEY_FLAG_RESERVE_TAILROOM)) { /* hwaccel - with no need for software-generated IV */ return 0; } @@ -200,7 +202,8 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) hdrlen = ieee80211_hdrlen(hdr->frame_control); len = skb->len - hdrlen; - if (info->control.hw_key) + if (info->control.hw_key && !(info->control.hw_key->flags & + IEEE80211_KEY_FLAG_RESERVE_TAILROOM)) tail = 0; else tail = IEEE80211_TKIP_ICV_LEN; @@ -227,8 +230,12 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) spin_unlock(&key->u.tkip.txlock); /* hwaccel - with software IV */ - if (info->control.hw_key) + if (info->control.hw_key) { + if (info->control.hw_key->flags & + IEEE80211_KEY_FLAG_RESERVE_TAILROOM) + skb_put(skb, tail); return 0; + } /* Add room for ICV */ skb_put(skb, IEEE80211_TKIP_ICV_LEN); @@ -411,6 +418,8 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb, if (info->control.hw_key && !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) && !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && + !(info->control.hw_key->flags & + IEEE80211_KEY_FLAG_RESERVE_TAILROOM) && !((info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV_MGMT) && ieee80211_is_mgmt(hdr->frame_control))) { @@ -424,7 +433,8 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb, hdrlen = ieee80211_hdrlen(hdr->frame_control); len = skb->len - hdrlen; - if (info->control.hw_key) + if (info->control.hw_key && !(info->control.hw_key->flags & + IEEE80211_KEY_FLAG_RESERVE_TAILROOM)) tail = 0; else tail = mic_len; @@ -456,8 +466,12 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb, ccmp_pn2hdr(pos, pn, key->conf.keyidx); /* hwaccel - with software CCMP header */ - if (info->control.hw_key) + if (info->control.hw_key) { + if (info->control.hw_key->flags & + IEEE80211_KEY_FLAG_RESERVE_TAILROOM) + skb_put(skb, tail); return 0; + } pos += IEEE80211_CCMP_HDR_LEN; ccmp_special_blocks(skb, pn, b_0, aad);