From patchwork Fri May 26 22:49:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norik Dzhandzhapanyan X-Patchwork-Id: 9751241 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0C4960249 for ; Fri, 26 May 2017 22:50:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A759A28474 for ; Fri, 26 May 2017 22:50:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A79B284C0; Fri, 26 May 2017 22:50:24 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 DE8B02848D for ; Fri, 26 May 2017 22:50:23 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=kEfoHsh3EXF5HLSymOvKvzctj++m1uVidMXAeGdjmqc=; b=PkHKB/7RRIsZ2w i9sh0pldM39pzu47LKA/B5w+ucTLDh1PjeGaWzqM55EHXXE0aDs2o6hgolQvwhyfOAO5vpA83K++o XuBaP5j9q9cWUjlqD/UbyZnIPQQzRli0pdaQR6VtkWYBu44Mjjr1VwCYlDqbzbmYLcSVbJ05e6s0h ao1KFP9BwIhTJNeP5MTsNThI+PhZ3518lafNwFhbICVb7qjRanGKmPgzvkvn+hAhm1+a8jDkYrJKp a2XCCApCAkF/jP5o1CZULII7gLg5gWrRyoEIaS/LTbyc198H4z62myoEhDNupsgNcrL517b/GoPL+ uS7AeqF3j48LW9Wz0gqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dEO3f-0000oH-5E; Fri, 26 May 2017 22:50:11 +0000 Received: from mail-sn1nam01on0057.outbound.protection.outlook.com ([104.47.32.57] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dEO3b-00082C-Sm for ath10k@lists.infradead.org; Fri, 26 May 2017 22:50:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ETHERTRONICS.onmicrosoft.com; s=selector1-ethertronics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rhGyJzruFbSj0z5Iptjualsrp03VQ5E5iknbD39V9/E=; b=Pxr918ONwErhbIU5udIPDT1DNDZ8+zA9iqqNjIlhFcNOobvQFhSVed2C93XCQDlK3eCwpeWoD3adMT2z4mTjBhjQTzkVYKcdEhrO7U4ptZ0pV32ju/pUB4IT7KcbDYPr2wm9A8pt1DRU1/5Oi+uqd8DOpu4lktppt8mPV0rUaxE= Received: from SN1PR08MB1373.namprd08.prod.outlook.com (10.162.1.143) by SN1PR08MB1376.namprd08.prod.outlook.com (10.162.1.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Fri, 26 May 2017 22:49:45 +0000 Received: from SN1PR08MB1373.namprd08.prod.outlook.com ([10.162.1.143]) by SN1PR08MB1373.namprd08.prod.outlook.com ([10.162.1.143]) with mapi id 15.01.1124.009; Fri, 26 May 2017 22:49:45 +0000 From: Norik Dzhandzhapanyan To: "ath10k@lists.infradead.org" Subject: [PATCH] Per chain RSSI reporting Thread-Topic: [PATCH] Per chain RSSI reporting Thread-Index: AdLWcj3v2v9UyNqcRR+HUAdHIt6PYg== Date: Fri, 26 May 2017 22:49:45 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: lists.infradead.org; dkim=none (message not signed) header.d=none; lists.infradead.org; dmarc=none action=none header.from=ethertronics.com; x-originating-ip: [64.58.179.102] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN1PR08MB1376; 7:B4PgqX1uTRS91xz2OnNZ8Df8V+SmB6ee9/z1lQhxG5Lx+qPXrXGV+Mo4T5lOWmRtaJx9U04YUP0Ord+ThJaAa2hSetrtGfKZiM5Rjd9XmXY2aameOZ6hyFhr3mSrIJ+rkanBoB8gK2g46cmBt2JvzWEkJzcHNleNbzn8l1apJX6TjTj+TJ8k4iVNDk49q8AbPS3PI5INM4fszb1cF047JDDIqwCaTMoNBhhHV+AZvQTXFdb+2CvI4RxrlNijKckGG7a+gvfjBEWZa3WkWJrLvq+WLcbzuxrWWjezbUUurIPkPMlYh9RaUH2cN28+VzGisKRFpX1xofiqE/eyDSCiYQ== x-ms-traffictypediagnostic: SN1PR08MB1376: x-ms-office365-filtering-correlation-id: 1d047932-81c6-4158-68c7-08d4a4898169 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081); SRVR:SN1PR08MB1376; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(211171220733660); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123562025)(6072148); SRVR:SN1PR08MB1376; BCL:0; PCL:0; RULEID:; SRVR:SN1PR08MB1376; x-forefront-prvs: 031996B7EF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39400400002)(39450400003)(39410400002)(39830400002)(377424004)(2906002)(7696004)(6916009)(7736002)(122556002)(9686003)(74316002)(2900100001)(53936002)(66066001)(14454004)(99286003)(55016002)(4326008)(305945005)(54356999)(3846002)(6116002)(102836003)(25786009)(77096006)(50986999)(8676002)(38730400002)(5640700003)(3660700001)(86362001)(2351001)(6506006)(478600001)(3280700002)(2501003)(6436002)(5660300001)(8936002)(81166006)(189998001)(33656002)(110136004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR08MB1376; H:SN1PR08MB1373.namprd08.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: ethertronics.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2017 22:49:45.2564 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 23df5a5b-1d17-4d79-93b8-588ba3e5294c X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR08MB1376 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170526_155008_012873_9EA83AD5 X-CRM114-Status: GOOD ( 10.01 ) 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" Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for per chain RSSI reporting w/smoothing. Signed-off-by: Norik Dzhandzhapanyan norikd@ethertronics.com The contents of this transmission are Ethertronics Inc. Confidential and may contain proprietary or legally privileged information which may not be disclosed, copied or distributed without the express written consent of Ethertronics Inc. The information is intended to be for the use of the individual or entity named on this transmission. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this transmission in error, please notify us by telephone immediately so that we can arrange for the retrieval of the original documents at no cost to you. Alternatively, notify the sender by replying to this transmission and delete the message without disclosing it. Thank you --- htt_rx.c.orig 2017-05-26 15:26:37.918504255 -0700 +++ htt_rx.c 2017-05-26 12:10:33.139809025 -0700 @@ -825,14 +825,71 @@ static bool ath10k_htt_rx_h_channel(stru return true; } +/* + * Signal data is somewhat glitchy. We smooth it out here with + * a 16 point moving average by storing samples in a buffer. + * As new samples come in, remove the oldest and add the newest + * to the running sum. Avoids changes/impact to other generic averaging. + */ + +/* Moving average buffer */ +#define MA_SAMPLES (16) + +struct ma_buffer +{ + int count; + int head; + int tail; + int sum; + int samps[MA_SAMPLES]; +}; + +struct ma_buffer ma_buffers[IEEE80211_MAX_CHAINS] = {{ 0 }}; + +static int ath_cb_moving_average(struct ma_buffer *mb, int8_t samp) +{ + if (mb->count < MA_SAMPLES) { + mb->count++; + mb->sum += samp; + mb->tail = 0; + } else { + int oldest = mb->samps[mb->tail]; + mb->tail = (mb->head == MA_SAMPLES - 1) ? 0 : mb->head + 1; + mb->sum = mb->sum - oldest + samp; + } + + mb->samps[mb->head] = samp; + mb->head = (mb->head == MA_SAMPLES - 1) ? 0 : mb->head + 1; + + return (mb->sum / mb->count); +} + static void ath10k_htt_rx_h_signal(struct ath10k *ar, struct ieee80211_rx_status *status, struct htt_rx_desc *rxd) { - /* FIXME: Get real NF */ - status->signal = ATH10K_DEFAULT_NOISE_FLOOR + - rxd->ppdu_start.rssi_comb; - status->flag &= ~RX_FLAG_NO_SIGNAL_VAL; + int i; + + for(i=0;ichains &= ~BIT(i); + + if (rxd->ppdu_start.rssi_chains[i].pri20_mhz != 0x80) + { + int8_t rssi = ATH10K_DEFAULT_NOISE_FLOOR + + rxd->ppdu_start.rssi_chains[i].pri20_mhz; + + status->chains |= BIT(i); + + /* Compute the moving average of rssi */ + status->chain_signal[i] = ath_cb_moving_average(&ma_buffers[i], rssi); + } + } + + /* FIXME: Get real NF */ + status->signal = ATH10K_DEFAULT_NOISE_FLOOR + + rxd->ppdu_start.rssi_comb; + status->flag &= ~RX_FLAG_NO_SIGNAL_VAL; } static void ath10k_htt_rx_h_mactime(struct ath10k *ar,