From patchwork Tue Jun 20 00:32:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9798295 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 7D9F660328 for ; Tue, 20 Jun 2017 00:32:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7287326E51 for ; Tue, 20 Jun 2017 00:32:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67601274D0; Tue, 20 Jun 2017 00:32:36 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 0ADAC26E51 for ; Tue, 20 Jun 2017 00:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbdFTAce (ORCPT ); Mon, 19 Jun 2017 20:32:34 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:35907 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752475AbdFTAcc (ORCPT ); Mon, 19 Jun 2017 20:32:32 -0400 Received: by mail-oi0-f68.google.com with SMTP id g14so10724142oib.3 for ; Mon, 19 Jun 2017 17:32:32 -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=6StUOJ5pxTgdYSIpQXpki2CMPiaS9rHt5LAyO7rIBNw=; b=Ow78MbbOuic6Y8c3M5ww+TGraGC/1vkW4prpKSbxiL5OS9CruFnkNxRyr2EQC/J78P hkJMdyR3xBLElGQV4DQI3O5+Z5viodar6sSOrItNRYXyXga/0VsM2fU+gkTTGSiK2lg0 EWUK89intdTkBtl/KDEkBEfNzbDlKdoiVM4CStWbHdYvSdRNu4NKKGKTe/vLUHAc9JOC lyS6moJ+eN+anfB/jzs8HuiO1GgJDc1mpfUYomf5yWisUx+PSwmr9eXOExeAsH3G5dZx PaalRpVflUeh+OG955hqPPO3LKrc1qndUBvvFuctbF6Ab4QNRyPEMUewmwlkapVY+mj6 pHxQ== 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=6StUOJ5pxTgdYSIpQXpki2CMPiaS9rHt5LAyO7rIBNw=; b=WeyNaK+YhjIzQm19ucl+fAEob8Z8rOJl3F5SczJvZgM+GD5MposYjs5XluK4H6Ns52 LG21YSWIAtbjUZIMMx5IWtDMg1ChSY6ookDsoTn8Sh4hjbfurLaY/XeGo7quYQXqZY9t EknU+47QxoQ0X/56pl3RETCWz0VbpsY7ewfHO37jvE/jY4RKufKcA2F+I7z4UJ7G87TD 57m+PCVnzQ9MPswA2vn6+WSxbQk/QfawK8XS5quudfPqZKnzrB63gAjR3Szl9DepHyuh +1uCq4pD87lc/95g7z7XaNa1XBaQH15aNxBRFY/r7MonEdlmQhLgPeweLsWw+xKj5K7/ jaFw== X-Gm-Message-State: AKS2vOxMrrvDoUHRBZLMtcY4Nr29hNXJegHhf/2binj5osEnmMt/JDC/ sCbYbDYSslOCug== X-Received: by 10.202.198.135 with SMTP id w129mr12668853oif.82.1497918751947; Mon, 19 Jun 2017 17:32:31 -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 198sm5841023oii.16.2017.06.19.17.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Jun 2017 17:32:31 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, Ping-Ke Shih , Larry Finger , Yan-Hsuan Chuang , Birming Chiu , Shaofu , Steven Ting Subject: [PATCH 07/10] rtlwifi: Fill ap_num filed by vendor command Date: Mon, 19 Jun 2017 19:32:15 -0500 Message-Id: <20170620003218.17010-8-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170620003218.17010-1-Larry.Finger@lwfinger.net> References: <20170620003218.17010-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: Ping-Ke Shih The ap_num can be filled by wpa_cli's VENDOR command. Signed-off-by: Ping-Ke Shih Signed-off-by: Larry Finger Cc: Yan-Hsuan Chuang Cc: Birming Chiu Cc: Shaofu Cc: Steven Ting --- drivers/net/wireless/realtek/rtlwifi/base.c | 64 ++++++++++++++++++++++++++++ drivers/net/wireless/realtek/rtlwifi/debug.h | 1 + 2 files changed, 65 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c index 180850cb4671..1994125a21b5 100644 --- a/drivers/net/wireless/realtek/rtlwifi/base.c +++ b/drivers/net/wireless/realtek/rtlwifi/base.c @@ -315,6 +315,67 @@ static void _rtl_init_hw_vht_capab(struct ieee80211_hw *hw, } } +#define OUI_REALTEK 0x00E04C + +enum { + RTL_VENDOR_SCMD_COEX_AP_NUM = 2000, +}; + +static u32 rtl_data_to_int(struct rtl_priv *rtlpriv, const void *data, int len) +{ + /* wpa_supplicant translates the string '01234567' to binary as + * '01 23 45 67', so we treat it as big-endian. + */ + u32 tmp = 0; + + switch (len) { + case 1: + tmp = *((u8 *)data); + break; + case 2: + tmp = be16_to_cpu(*((__be16 *)data)); + break; + case 4: + tmp = be32_to_cpu(*((__be32 *)data)); + break; + default: + RT_TRACE(rtlpriv, COMP_VENDOR_CMD, DBG_WARNING, + "length of vendor command is %d\n", len); + break; + } + + return tmp; +} + +static int rtl_cfgvendor_coex_ap_num(struct wiphy *wiphy, + struct wireless_dev *wdev, + const void *data, int len) +{ + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->btcoexist.btc_info.ap_num = + rtl_data_to_int(rtlpriv, data, len); + + RT_TRACE(rtlpriv, COMP_VENDOR_CMD, DBG_DMESG, + "cfgvendor ap_num is %d\n", + rtlpriv->btcoexist.btc_info.ap_num); + + return 0; +} + +static const struct wiphy_vendor_command rtl_vendor_cmds[] = { + { + { + .vendor_id = OUI_REALTEK, + .subcmd = RTL_VENDOR_SCMD_COEX_AP_NUM + }, + .flags = WIPHY_VENDOR_CMD_NEED_WDEV | + WIPHY_VENDOR_CMD_NEED_NETDEV, + .doit = rtl_cfgvendor_coex_ap_num, + }, +}; + static void _rtl_init_mac80211(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -323,6 +384,9 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); struct ieee80211_supported_band *sband; + hw->wiphy->vendor_commands = rtl_vendor_cmds; + hw->wiphy->n_vendor_commands = ARRAY_SIZE(rtl_vendor_cmds); + if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY && rtlhal->bandset == BAND_ON_BOTH) { /* 1: 2.4 G bands */ diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.h b/drivers/net/wireless/realtek/rtlwifi/debug.h index 947718001457..b39e87cc568a 100644 --- a/drivers/net/wireless/realtek/rtlwifi/debug.h +++ b/drivers/net/wireless/realtek/rtlwifi/debug.h @@ -106,6 +106,7 @@ #define COMP_BT_COEXIST BIT(30) #define COMP_IQK BIT(31) #define COMP_TX_REPORT BIT_ULL(32) +#define COMP_VENDOR_CMD BIT_ULL(33) /*-------------------------------------------------------------- Define the rt_print components