From patchwork Wed Apr 29 23:51:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Kossifidis X-Patchwork-Id: 6299241 X-Patchwork-Delegate: kvalo@adurom.com 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 2DC51BEEE1 for ; Wed, 29 Apr 2015 23:52:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48702201B9 for ; Wed, 29 Apr 2015 23:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 414E0201B4 for ; Wed, 29 Apr 2015 23:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751823AbbD2XwK (ORCPT ); Wed, 29 Apr 2015 19:52:10 -0400 Received: from mail-ie0-f177.google.com ([209.85.223.177]:36625 "EHLO mail-ie0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751773AbbD2XwJ (ORCPT ); Wed, 29 Apr 2015 19:52:09 -0400 Received: by iebrs15 with SMTP id rs15so55326771ieb.3 for ; Wed, 29 Apr 2015 16:52:08 -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:in-reply-to:references; bh=PNIn6Mf9jMLA3iDv69o3D2HOGH3Ga4B8zeMeCMhLvTE=; b=wOooyZzM/ZzqCWiNxz8VZf/0W+tloorWszSziITmtjM95k1KbM2kI62RBD/SWgef5h 6iByRDk/WrSKMeFapgAcUcQTDfYiagGtiv6d8DIBEt9RWrLUjSVKDSHJjqNBDNKCu4zz jgkfPRyEt1GjVtizcD6CiL9Mk0po3LUZG4/fTRPhWGWJXYlgqcPz17Cb8dmZygxi99CL ZKQv5yCfrPNGqtafh8V95YlgDyvLyqqFkCm8zjZiPfxTR7a7tJiSRwH8rAjCP5H242ov WaQCwjuCEDgA3uBVg5ceIebhy9TsFG9F4pEh2td6m85OceWb+jbqnvMDbK0SEQpj7OBG BPTQ== X-Received: by 10.42.99.205 with SMTP id x13mr6567082icn.53.1430351528588; Wed, 29 Apr 2015 16:52:08 -0700 (PDT) Received: from cobra (rochester-wireless-nat.mayo.edu. [129.176.197.220]) by mx.google.com with ESMTPSA id n5sm660959igp.10.2015.04.29.16.52.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 16:52:08 -0700 (PDT) Received: by cobra (sSMTP sendmail emulation); Wed, 29 Apr 2015 23:52:06 +0000 From: "Nick Kossifidis" To: kvalo@codeaurora.org, ath9k-devel@qca.qualcomm.com Cc: linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org, adrian.chadd@gmail.com, Nick Kossifidis Subject: [PATCH 06/11] ath9k: Skip malformed frames on normal FFT report Date: Wed, 29 Apr 2015 23:51:17 +0000 Message-Id: <1430351482-59418-7-git-send-email-mickflemm@gmail.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1430351482-59418-1-git-send-email-mickflemm@gmail.com> References: <1430351482-59418-1-git-send-email-mickflemm@gmail.com> 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 Since we have lots of frames on a normal FFT report don't bother processing the malformed ones. Only try to fix malformed frames in case of a short FFT report (only a single frame on the report). Signed-off-by: Nick Kossifidis --- drivers/net/wireless/ath/ath9k/common-spectral.c | 94 ++++++++++++++++-------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/common-spectral.c b/drivers/net/wireless/ath/ath9k/common-spectral.c index 51ab396..0c9bc9e 100644 --- a/drivers/net/wireless/ath/ath9k/common-spectral.c +++ b/drivers/net/wireless/ath/ath9k/common-spectral.c @@ -437,6 +437,42 @@ ath_cmn_process_ht20_40_fft(struct ath_rx_status *rs, return 0; } +static inline void +ath_cmn_copy_fft_frame(u8 *in, u8 *out, int sample_len, int sample_bytes) +{ + switch (sample_bytes - sample_len) { + case -1: + /* First byte missing */ + memcpy(&out[1], in, + sample_len - 1); + break; + case 0: + /* Length correct, nothing to do. */ + memcpy(out, in, sample_len); + break; + case 1: + /* MAC added 2 extra bytes AND first byte + * is missing. + */ + memcpy(&out[1], in, 30); + out[31] = in[31]; + memcpy(&out[32], &in[33], + sample_len - 32); + break; + case 2: + /* MAC added 2 extra bytes at bin 30 and 32, + * remove them. + */ + memcpy(out, in, 30); + out[30] = in[31]; + memcpy(&out[31], &in[33], + sample_len - 31); + break; + default: + break; + } +} + /* returns 1 if this was a spectral frame, even if not handled. */ int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr, struct ath_rx_status *rs, u64 tsf) @@ -570,46 +606,40 @@ int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_h if (got_slen) { ath_dbg(common, SPECTRAL_SCAN, "FFT frame len: %i\n", sample_bytes); - switch (sample_bytes - sample_len) { - case -1: - /* First byte missing */ - memcpy(&sample_buf[1], sample_start, - sample_len - 1); - break; - case 0: - /* Length correct, nothing to do. */ + + /* Only try to fix a frame if it's the only one + * on the report, else just skip it. + */ + if (sample_bytes != sample_len && len <= fft_len + 2) { + ath_cmn_copy_fft_frame(sample_start, + sample_buf, sample_len, + sample_bytes); + + fft_handler(rs, spec_priv, sample_buf, + tsf, freq, chan_type); + } + + /* Process a normal frame */ + if (sample_bytes == sample_len) { memcpy(sample_buf, sample_start, sample_len); - break; - case 1: - /* MAC added 2 extra bytes AND first byte - * is missing. - */ - memcpy(&sample_buf[1], sample_start, 30); - sample_buf[31] = sample_start[31]; - memcpy(&sample_buf[32], &sample_start[33], - sample_len - 32); - break; - case 2: - /* MAC added 2 extra bytes at bin 30 and 32, - * remove them. - */ - memcpy(sample_buf, sample_start, 30); - sample_buf[30] = sample_start[31]; - memcpy(&sample_buf[31], &sample_start[33], - sample_len - 31); - break; - default: - break; + ret = fft_handler(rs, spec_priv, sample_buf, + tsf, freq, chan_type); } - ret = fft_handler(rs, spec_priv, sample_buf, tsf, - freq, chan_type); + /* Short report processed, break out of the + * loop. + */ + if (len <= fft_len + 2) + break; + memset(sample_buf, 0, SPECTRAL_SAMPLE_MAX_LEN); sample_start = &vdata[i + 1]; + /* -1 to grab sample_len -1, -2 since * they 'll get increased by one. In case * of failure try to recover by going byte - * by byte instead. */ + * by byte instead. + */ if (ret == 0) { i += num_bins - 2; sample_bytes = num_bins - 2;