From patchwork Fri Apr 26 06:41:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 10918353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BC381395 for ; Fri, 26 Apr 2019 06:41:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED56328A32 for ; Fri, 26 Apr 2019 06:41:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB85828DAD; Fri, 26 Apr 2019 06:41:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA8B728D7A for ; Fri, 26 Apr 2019 06:41:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=eo/bsjP/KuO4X0MF5X+/xFFwli2XRSk3kBdTf3lRnc8=; b=H9C7C3IyHXn3mTpy1UZvWK6rmU NFcAA8LaYuUcV8NESM5DPWroUoE8bCr2GBMnJsJY8P1yD0J6mMP/rS4ljuJmWGpKWR/WzC3VISB/2 kwJ+fd79SBDhTmKnNfb4p7iC9b5ZyE1jtJg6WC96JwbLmr+n5v7kBNvxk4ngyagU3yLVEdMBTKSqN lcAPtqEd64G3YJjYj9TBP6M6VDvntTJ+zhIb1PzxLUYl75VCYM8anyDt+LObCmlTnIikuQSWwA83z tkRw3Qxudcm8LsIbUcF0Z7o/K5/Q3I/9ELVfL6kLAAv8AUghJaBa71dZmjXEOsbClGB27a1DFSgvO snHvKN4A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJuXz-0007c3-U3; Fri, 26 Apr 2019 06:41:23 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJuXw-0007Y1-2G for ath10k@lists.infradead.org; Fri, 26 Apr 2019 06:41:21 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C77FB60746; Fri, 26 Apr 2019 06:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1556260879; bh=snHt1zZnlCOet6D7tR9i7A1sc/XYSmTmIdk/h9mbjc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3NwH/k7c+/oxUVFRC2pM/7Z4IOUtaAksaf/kNzQiJcGD74A7t9y0DxInEFUfu7h7 W/jbjR1JeIC44oC7TDWOOlrlas9LQ5nURJEOZrlRSKF/5Bt0CrDmzWd1PLowj9Fln6 go6O1MIc85cWhehSJrjBtIe2sfAda5KDTmmi8kmo= Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5DED56076C; Fri, 26 Apr 2019 06:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1556260879; bh=snHt1zZnlCOet6D7tR9i7A1sc/XYSmTmIdk/h9mbjc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3NwH/k7c+/oxUVFRC2pM/7Z4IOUtaAksaf/kNzQiJcGD74A7t9y0DxInEFUfu7h7 W/jbjR1JeIC44oC7TDWOOlrlas9LQ5nURJEOZrlRSKF/5Bt0CrDmzWd1PLowj9Fln6 go6O1MIc85cWhehSJrjBtIe2sfAda5KDTmmi8kmo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5DED56076C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: ath10k@lists.infradead.org Subject: [PATCH 2/5] ath10k: add handler for HTT_T2H_MSG_TYPE_SEC_IND event Date: Fri, 26 Apr 2019 09:41:08 +0300 Message-Id: <1556260871-2919-3-git-send-email-kvalo@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556260871-2919-1-git-send-email-kvalo@codeaurora.org> References: <1556260871-2919-1-git-send-email-kvalo@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190425_234120_149227_0EBAE877 X-CRM114-Status: GOOD ( 10.89 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, Wen Gong MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wen Gong Add the handler for HTT_T2H_MSG_TYPE_SEC_IND event from firmware, which stores PN for replay check implemented in the following patch. Tested on QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00007-QCARMSWP-1. Signed-off-by: Wen Gong Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath10k/htt_rx.c | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index f22840bbc389..cc2875d73bf0 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -3267,6 +3267,51 @@ static void ath10k_fetch_10_2_tx_stats(struct ath10k *ar, u8 *data) rcu_read_unlock(); } +static int ath10k_htt_rx_pn_len(enum htt_security_types sec_type) +{ + switch (sec_type) { + case HTT_SECURITY_TKIP: + case HTT_SECURITY_TKIP_NOMIC: + case HTT_SECURITY_AES_CCMP: + return 48; + default: + return 0; + } +} + +static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar, + struct htt_security_indication *ev) +{ + enum htt_txrx_sec_cast_type sec_index; + enum htt_security_types sec_type; + struct ath10k_peer *peer; + + spin_lock_bh(&ar->data_lock); + + peer = ath10k_peer_find_by_id(ar, __le16_to_cpu(ev->peer_id)); + if (!peer) { + ath10k_warn(ar, "failed to find peer id %d for security indication", + __le16_to_cpu(ev->peer_id)); + goto out; + } + + sec_type = MS(ev->flags, HTT_SECURITY_TYPE); + + if (ev->flags & HTT_SECURITY_IS_UNICAST) + sec_index = HTT_TXRX_SEC_UCAST; + else + sec_index = HTT_TXRX_SEC_MCAST; + + peer->rx_pn[sec_index].sec_type = sec_type; + peer->rx_pn[sec_index].pn_len = ath10k_htt_rx_pn_len(sec_type); + + memset(peer->tids_last_pn_valid, 0, sizeof(peer->tids_last_pn_valid)); + memset(peer->tids_last_pn, 0, sizeof(peer->tids_last_pn)); + +out: + spin_unlock_bh(&ar->data_lock); +} + bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) { struct ath10k_htt *htt = &ar->htt; @@ -3360,6 +3405,7 @@ bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) struct ath10k *ar = htt->ar; struct htt_security_indication *ev = &resp->security_indication; + ath10k_htt_rx_sec_ind_handler(ar, ev); ath10k_dbg(ar, ATH10K_DBG_HTT, "sec ind peer_id %d unicast %d type %d\n", __le16_to_cpu(ev->peer_id),