From patchwork Sat May 31 16:30:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 4276271 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 91959BEEAA for ; Sat, 31 May 2014 16:31:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3C5F2010C for ; Sat, 31 May 2014 16:31:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8BF720127 for ; Sat, 31 May 2014 16:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753986AbaEaQbP (ORCPT ); Sat, 31 May 2014 12:31:15 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:41129 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753727AbaEaQbL (ORCPT ); Sat, 31 May 2014 12:31:11 -0400 Received: by mail-wi0-f181.google.com with SMTP id n15so2652038wiw.8 for ; Sat, 31 May 2014 09:31:10 -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=0ZewDSzra02IphMlGlZubN7TZPpsWiFH9upAcPhWKWE=; b=l38nvv2afFVjd3XQGHZNnWiaBryWKhXxU7XuS7J6wZWVTqigPONcafj/YXy348SlX8 KuHSx5sXSzAC0F6VsxrJJyI7So606G3Jjod/ByQi5KYH4eJKxxxIwCzNpaPdpguT8teU 0bKF/CSmdvyj3oig+AL8gn7jpGO0skpcRvR7tYKVYGhdxCfYmaX/q5Qg17AL51dG1hAF EKFwShDgrIRmqKF/JycfeQTJFdZ281xtFuMAE7g1WwU8tCxrSOe5sA0mZWhBRRY7O59z TJtP+p9ykKfGMmUZfAV/4mQMpIlSvL+eriwLP1oaOVcoi6MddlCnraOdDubfYSD7jKCK qKcw== X-Received: by 10.180.7.227 with SMTP id m3mr7168388wia.59.1401553870167; Sat, 31 May 2014 09:31:10 -0700 (PDT) Received: from localhost.localdomain (host84-87-dynamic.7-79-r.retail.telecomitalia.it. [79.7.87.84]) by mx.google.com with ESMTPSA id ey3sm15965305wib.18.2014.05.31.09.31.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 May 2014 09:31:09 -0700 (PDT) From: Andrea Merello To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, dan.carpenter@oracle.com, Andrea Merello Subject: [RFT] rtl818x_pci: add RSSI information for rtl8187SE Date: Sat, 31 May 2014 18:30:58 +0200 Message-Id: <1401553858-7784-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This patch makes the driver to report signal stength information to mac80211 for rtl8187se boards. My card has probably an HW problem, because it suffers of bad RX sensitivity (even on other OSes), so I could only test that the information is somewhat proportional to the signal RXed. Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index 1e25929..b41267c 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -188,6 +188,9 @@ static const int rtl8187se_queues_map[RTL8187SE_NR_TX_QUEUES] = {5, 4, 3, 2, 7}; static const int rtl8180_queues_map[RTL8180_NR_TX_QUEUES] = {4, 7}; +/* LNA gain table for rtl8187se */ +static const u8 rtl8187se_lna_gain[4] = {02, 17, 29, 39}; + void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data) { struct rtl8180_priv *priv = dev->priv; @@ -215,7 +218,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) while (count--) { void *entry = priv->rx_ring + priv->rx_idx * priv->rx_ring_sz; struct sk_buff *skb = priv->rx_buf[priv->rx_idx]; - u32 flags, flags2; + u32 flags, flags2, flags3; u64 tsft; if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { @@ -229,6 +232,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) */ rmb(); flags2 = le32_to_cpu(desc->flags2); + flags3 = le32_to_cpu(desc->flags3); tsft = le64_to_cpu(desc->tsft); } else { struct rtl8180_rx_desc *desc = entry; @@ -237,6 +241,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) /* same as above */ rmb(); flags2 = le32_to_cpu(desc->flags2); + flags3 = 0; /* not used. get rid of GCC warn */ tsft = le64_to_cpu(desc->tsft); } @@ -275,6 +280,11 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) agc = (flags2 >> 17) & 0x7F; switch (priv->chip_family) { + case RTL818X_CHIP_FAMILY_RTL8187SE: + /* bias + BB gain + LNA gain */ + agc = -4 + (agc & 0x1F) * 2 + + rtl8187se_lna_gain[(agc & 0x60) >> 5]; + /* fall through */ case RTL818X_CHIP_FAMILY_RTL8185: if (rx_status.rate_idx > 3) signal = -clamp_t(u8, agc, 25, 90) - 9; @@ -285,10 +295,6 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) sq = flags2 & 0xff; signal = priv->rf->calc_rssi(agc, sq); break; - case RTL818X_CHIP_FAMILY_RTL8187SE: - /* TODO: rtl8187se rssi */ - signal = 10; - break; } rx_status.signal = signal; rx_status.freq = dev->conf.chandef.chan->center_freq; @@ -1819,7 +1825,7 @@ static int rtl8180_probe(struct pci_dev *pdev, pci_try_set_mwi(pdev); } - if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) + if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) dev->flags |= IEEE80211_HW_SIGNAL_DBM; else dev->flags |= IEEE80211_HW_SIGNAL_UNSPEC;