From patchwork Thu Apr 13 18:06:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9679785 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 7B51B601C3 for ; Thu, 13 Apr 2017 18:07:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 715272869E for ; Thu, 13 Apr 2017 18:07:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63BE8286AD; Thu, 13 Apr 2017 18:07:34 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 175542869E for ; Thu, 13 Apr 2017 18:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755406AbdDMSHZ (ORCPT ); Thu, 13 Apr 2017 14:07:25 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:35573 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755198AbdDMSHT (ORCPT ); Thu, 13 Apr 2017 14:07:19 -0400 Received: by mail-oi0-f65.google.com with SMTP id g204so13596968oib.2 for ; Thu, 13 Apr 2017 11:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=f4L1zi6JHXMwgijDNV81lshgKnb9Nrx5Vi6MEeHfSA8=; b=RwyALcT+wefr6PhdFr22iQ9+eMAbHz3jGmrEminisDkR7vQLjgCD0MpgyO4GL1dEHc bn/XkjcCFKcZrFuo/ZTYYgGHmO7G9xMGqOWO4FlVOqzw4B36PlJimREFKDgYtBwYMDXD tz+D0+1sPkToWbG08w9pwKgGdNZzwitxcY1/yGDJf/4dEnw6CseceLydIpX6rT6DmI9c AmwxJVWu0TxZ6SUhPUdIV7urzCrUFqsKw702fKptmfRgV/BD3CZxdCLT8R40d2MNg9Nr DlMZ3vpa1ua84mFd2jA4E6dpUQD0QGUEdUXD0m6k74v8tBsSDPIfmElJPK1hBqR7Nfjd Bxwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=f4L1zi6JHXMwgijDNV81lshgKnb9Nrx5Vi6MEeHfSA8=; b=hXE94y8DskiFrr3yfvPqRe4yn9Xv6OpyIuyXE47nVfWaRRidt0LEyl37JUBqgO5sPW nzabTave0tZ+OTB67zz0UogbpunVGfYT10HVuF06kx5IxYkLFn+Ku/z1Ks7DZCsqc0Xb st4L5UrT5m3ozWxkJm/EPRXjPM4xikJFCOcQAcmFjPDcSf3j72Yjei9kwssZUUXpYGS2 /2dVeZ19GZWCumUqMCYPYz0F0aQUHjPBkZFbaRhzi+pCBxj4aXbCHo1N5eBQQ0eDWmZt iwdd+7S/VCAdF24oEM466xBKZUIEpMVtpKAzRDiZn66QLvtriPh+szFxWBM2g7yT/QHT Q7dg== X-Gm-Message-State: AN3rC/7Rl9ews8LtsxEmktmdYGPtAzw0P4qwVzvWsP/Ffzi0NrZWSnUN Iy0ibG8MxVbr0w== X-Received: by 10.202.5.195 with SMTP id 186mr2569453oif.59.1492106838211; Thu, 13 Apr 2017 11:07:18 -0700 (PDT) Received: from linux-4v1g.suse (cpe-24-31-249-175.kc.res.rr.com. [24.31.249.175]) by smtp.gmail.com with ESMTPSA id x54sm10897996otd.11.2017.04.13.11.07.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Apr 2017 11:07:17 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, Yan-Hsuan Chuang , Larry Finger , Pkshih , Birming Chiu , Shaofu , Steven Ting Subject: [PATCH 03/19] rtlwifi: btcoex: 21a 2ant: monitor wifi counter to check network status Date: Thu, 13 Apr 2017 13:06:54 -0500 Message-Id: <20170413180710.19953-4-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170413180710.19953-1-Larry.Finger@lwfinger.net> References: <20170413180710.19953-1-Larry.Finger@lwfinger.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yan-Hsuan Chuang If there are a lot of low-rate packets, then the connection of wifi is unstable. If so, we should switch resource to bt to have a higher transmission quality, or wifi resource will be wasted Signed-off-by: Yan-Hsuan Chuang Signed-off-by: Larry Finger Cc: Pkshih Cc: Birming Chiu Cc: Shaofu Cc: Steven Ting --- .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.c | 38 ++++++++++++++++++++++ .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.h | 10 ++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c index 7f685a02d865..e23670a23e4d 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c @@ -306,6 +306,43 @@ static void btc8821a2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); } +static void btc8821a2ant_monitor_wifi_ctr(struct btc_coexist *btcoexist) +{ + if (coex_sta->under_ips) { + coex_sta->crc_ok_cck = 0; + coex_sta->crc_ok_11g = 0; + coex_sta->crc_ok_11n = 0; + coex_sta->crc_ok_11n_agg = 0; + + coex_sta->crc_err_cck = 0; + coex_sta->crc_err_11g = 0; + coex_sta->crc_err_11n = 0; + coex_sta->crc_err_11n_agg = 0; + } else { + coex_sta->crc_ok_cck = + btcoexist->btc_read_4byte(btcoexist, 0xf88); + coex_sta->crc_ok_11g = + btcoexist->btc_read_2byte(btcoexist, 0xf94); + coex_sta->crc_ok_11n = + btcoexist->btc_read_2byte(btcoexist, 0xf90); + coex_sta->crc_ok_11n_agg = + btcoexist->btc_read_2byte(btcoexist, 0xfb8); + + coex_sta->crc_err_cck = + btcoexist->btc_read_4byte(btcoexist, 0xf84); + coex_sta->crc_err_11g = + btcoexist->btc_read_2byte(btcoexist, 0xf96); + coex_sta->crc_err_11n = + btcoexist->btc_read_2byte(btcoexist, 0xf92); + coex_sta->crc_err_11n_agg = + btcoexist->btc_read_2byte(btcoexist, 0xfba); + } + + /* reset counter */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x1); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x0); +} + static void btc8821a2ant_query_bt_info(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -2888,4 +2925,5 @@ void ex_btc8821a2ant_periodical(struct btc_coexist *btcoexist) btc8821a2ant_query_bt_info(btcoexist); btc8821a2ant_monitor_bt_ctr(btcoexist); + btc8821a2ant_monitor_wifi_ctr(btcoexist); } diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h index b4cf1f53d510..ce8e0d719e78 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h @@ -141,6 +141,16 @@ struct coex_sta_8821a_2ant { bool c2h_bt_inquiry_page; u8 bt_retry_cnt; u8 bt_info_ext; + + u32 crc_ok_cck; + u32 crc_ok_11g; + u32 crc_ok_11n; + u32 crc_ok_11n_agg; + + u32 crc_err_cck; + u32 crc_err_11g; + u32 crc_err_11n; + u32 crc_err_11n_agg; }; /*===========================================