staging: r8822be: Add existing rtlwifi and rtl_pci parts for new driver
The RTL8822BE, an 802.11ac wireless network card, is now appearing in new computers. Its driver is being placed in staging to reduce the time that users of this new card will have access to in-kernel drivers. This commit copies the code that currently constitutes the rtlwifi and rtl_pci mini drivers. This material is copied into staging to prevent any undo interaction between the existing drivers and this new one. The only changes in this code are the removal of all export statements, and the fixing of some checkpatch messages. The latter will be backported into the wireless tree. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Cc: Yan-Hsuan Chuang <yhchuang@realtek.com> Cc: Birming Chiu <birming@realtek.com> Cc: Shaofu <shaofu@realtek.com> Cc: Steven Ting <steventing@realtek.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
bf334c024f
Коммит
56bde84630
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,186 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_BASE_H__
|
||||
#define __RTL_BASE_H__
|
||||
|
||||
enum ap_peer {
|
||||
PEER_UNKNOWN = 0,
|
||||
PEER_RTL = 1,
|
||||
PEER_RTL_92SE = 2,
|
||||
PEER_BROAD = 3,
|
||||
PEER_RAL = 4,
|
||||
PEER_ATH = 5,
|
||||
PEER_CISCO = 6,
|
||||
PEER_MARV = 7,
|
||||
PEER_AIRGO = 9,
|
||||
PEER_MAX = 10,
|
||||
};
|
||||
|
||||
#define RTL_DUMMY_OFFSET 0
|
||||
#define RTL_DUMMY_UNIT 8
|
||||
#define RTL_TX_DUMMY_SIZE (RTL_DUMMY_OFFSET * RTL_DUMMY_UNIT)
|
||||
#define RTL_TX_DESC_SIZE 32
|
||||
#define RTL_TX_HEADER_SIZE (RTL_TX_DESC_SIZE + RTL_TX_DUMMY_SIZE)
|
||||
|
||||
#define MAX_BIT_RATE_40MHZ_MCS15 300 /* Mbps */
|
||||
#define MAX_BIT_RATE_40MHZ_MCS7 150 /* Mbps */
|
||||
|
||||
#define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9 867 /* Mbps */
|
||||
#define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS7 650 /* Mbps */
|
||||
#define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS9 780 /* Mbps */
|
||||
#define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS7 585 /* Mbps */
|
||||
|
||||
#define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9 434 /* Mbps */
|
||||
#define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS7 325 /* Mbps */
|
||||
#define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS9 390 /* Mbps */
|
||||
#define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS7 293 /* Mbps */
|
||||
|
||||
#define FRAME_OFFSET_FRAME_CONTROL 0
|
||||
#define FRAME_OFFSET_DURATION 2
|
||||
#define FRAME_OFFSET_ADDRESS1 4
|
||||
#define FRAME_OFFSET_ADDRESS2 10
|
||||
#define FRAME_OFFSET_ADDRESS3 16
|
||||
#define FRAME_OFFSET_SEQUENCE 22
|
||||
#define FRAME_OFFSET_ADDRESS4 24
|
||||
#define MAX_LISTEN_INTERVAL 10
|
||||
#define MAX_RATE_TRIES 4
|
||||
|
||||
#define SET_80211_HDR_FRAME_CONTROL(_hdr, _val) \
|
||||
WRITEEF2BYTE(_hdr, _val)
|
||||
#define SET_80211_HDR_TYPE_AND_SUBTYPE(_hdr, _val) \
|
||||
WRITEEF1BYTE(_hdr, _val)
|
||||
#define SET_80211_HDR_PWR_MGNT(_hdr, _val) \
|
||||
SET_BITS_TO_LE_2BYTE(_hdr, 12, 1, _val)
|
||||
#define SET_80211_HDR_TO_DS(_hdr, _val) \
|
||||
SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val)
|
||||
|
||||
#define SET_80211_PS_POLL_AID(_hdr, _val) \
|
||||
(*(u16 *)((u8 *)(_hdr) + 2) = _val)
|
||||
#define SET_80211_PS_POLL_BSSID(_hdr, _val) \
|
||||
ether_addr_copy(((u8 *)(_hdr)) + 4, (u8 *)(_val))
|
||||
#define SET_80211_PS_POLL_TA(_hdr, _val) \
|
||||
ether_addr_copy(((u8 *)(_hdr)) + 10, (u8 *)(_val))
|
||||
|
||||
#define SET_80211_HDR_DURATION(_hdr, _val) \
|
||||
(*(u16 *)((u8 *)(_hdr) + FRAME_OFFSET_DURATION) = le16_to_cpu(_val))
|
||||
#define SET_80211_HDR_ADDRESS1(_hdr, _val) \
|
||||
CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS1, (u8 *)(_val))
|
||||
#define SET_80211_HDR_ADDRESS2(_hdr, _val) \
|
||||
CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS2, (u8 *)(_val))
|
||||
#define SET_80211_HDR_ADDRESS3(_hdr, _val) \
|
||||
CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS3, (u8 *)(_val))
|
||||
#define SET_80211_HDR_FRAGMENT_SEQUENCE(_hdr, _val) \
|
||||
WRITEEF2BYTE((u8 *)(_hdr) + FRAME_OFFSET_SEQUENCE, _val)
|
||||
|
||||
#define SET_BEACON_PROBE_RSP_TIME_STAMP_LOW(__phdr, __val) \
|
||||
WRITEEF4BYTE(((u8 *)(__phdr)) + 24, __val)
|
||||
#define SET_BEACON_PROBE_RSP_TIME_STAMP_HIGH(__phdr, __val) \
|
||||
WRITEEF4BYTE(((u8 *)(__phdr)) + 28, __val)
|
||||
#define SET_BEACON_PROBE_RSP_BEACON_INTERVAL(__phdr, __val) \
|
||||
WRITEEF2BYTE(((u8 *)(__phdr)) + 32, __val)
|
||||
#define GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) \
|
||||
READEF2BYTE(((u8 *)(__phdr)) + 34)
|
||||
#define SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
|
||||
WRITEEF2BYTE(((u8 *)(__phdr)) + 34, __val)
|
||||
#define MASK_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
|
||||
SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, \
|
||||
(GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) & (~(__val))))
|
||||
|
||||
#define SET_TX_DESC_SPE_RPT(__pdesc, __val) \
|
||||
SET_BITS_TO_LE_4BYTE((__pdesc) + 8, 19, 1, __val)
|
||||
#define SET_TX_DESC_SW_DEFINE(__pdesc, __val) \
|
||||
SET_BITS_TO_LE_4BYTE((__pdesc) + 24, 0, 12, __val)
|
||||
|
||||
int rtl_init_core(struct ieee80211_hw *hw);
|
||||
void rtl_deinit_core(struct ieee80211_hw *hw);
|
||||
void rtl_init_rx_config(struct ieee80211_hw *hw);
|
||||
void rtl_init_rfkill(struct ieee80211_hw *hw);
|
||||
void rtl_deinit_rfkill(struct ieee80211_hw *hw);
|
||||
|
||||
void rtl_watch_dog_timer_callback(unsigned long data);
|
||||
void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
|
||||
|
||||
bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
|
||||
int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht,
|
||||
bool isvht, u8 desc_rate);
|
||||
bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
|
||||
u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
|
||||
bool is_enc);
|
||||
|
||||
bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb);
|
||||
void rtl_get_tx_report(struct rtl_tcb_desc *ptcb_desc, u8 *pdesc,
|
||||
struct ieee80211_hw *hw);
|
||||
void rtl_tx_report_handler(struct ieee80211_hw *hw, u8 *tmp_buf,
|
||||
u8 c2h_cmd_len);
|
||||
bool rtl_check_tx_report_acked(struct ieee80211_hw *hw);
|
||||
void rtl_wait_tx_report_acked(struct ieee80211_hw *hw, u32 wait_ms);
|
||||
u32 rtl_get_hal_edca_param(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
enum wireless_mode wirelessmode,
|
||||
struct ieee80211_tx_queue_params *param);
|
||||
|
||||
void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb);
|
||||
void rtl_collect_scan_list(struct ieee80211_hw *hw, struct sk_buff *skb);
|
||||
void rtl_scan_list_expire(struct ieee80211_hw *hw);
|
||||
int rtl_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
struct ieee80211_sta *sta, u16 tid, u16 *ssn);
|
||||
int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||
struct ieee80211_sta *sta, u16 tid);
|
||||
int rtl_tx_agg_oper(struct ieee80211_hw *hw,
|
||||
struct ieee80211_sta *sta, u16 tid);
|
||||
int rtl_rx_agg_start(struct ieee80211_hw *hw,
|
||||
struct ieee80211_sta *sta, u16 tid);
|
||||
int rtl_rx_agg_stop(struct ieee80211_hw *hw,
|
||||
struct ieee80211_sta *sta, u16 tid);
|
||||
void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv);
|
||||
void rtl_watchdog_wq_callback(void *data);
|
||||
void rtl_fwevt_wq_callback(void *data);
|
||||
void rtl_c2hcmd_wq_callback(void *data);
|
||||
void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec);
|
||||
void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val);
|
||||
|
||||
u8 rtl_mrate_idx_to_arfr_id(
|
||||
struct ieee80211_hw *hw, u8 rate_index,
|
||||
enum wireless_mode wirelessmode);
|
||||
void rtl_get_tcb_desc(struct ieee80211_hw *hw,
|
||||
struct ieee80211_tx_info *info,
|
||||
struct ieee80211_sta *sta,
|
||||
struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc);
|
||||
|
||||
int rtl_send_smps_action(struct ieee80211_hw *hw,
|
||||
struct ieee80211_sta *sta,
|
||||
enum ieee80211_smps_mode smps);
|
||||
u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie);
|
||||
void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len);
|
||||
u8 rtl_tid_to_ac(u8 tid);
|
||||
void rtl_easy_concurrent_retrytimer_callback(unsigned long data);
|
||||
extern struct rtl_global_var rtl_global_var;
|
||||
void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation);
|
||||
bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data,
|
||||
unsigned int len);
|
||||
int rtl_core_module_init(void);
|
||||
void rtl_core_module_exit(void);
|
||||
#endif
|
|
@ -0,0 +1,326 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include "wifi.h"
|
||||
#include "cam.h"
|
||||
#include <linux/export.h>
|
||||
|
||||
void rtl_cam_reset_sec_info(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
rtlpriv->sec.use_defaultkey = false;
|
||||
rtlpriv->sec.pairwise_enc_algorithm = NO_ENCRYPTION;
|
||||
rtlpriv->sec.group_enc_algorithm = NO_ENCRYPTION;
|
||||
memset(rtlpriv->sec.key_buf, 0, KEY_BUF_SIZE * MAX_KEY_LEN);
|
||||
memset(rtlpriv->sec.key_len, 0, KEY_BUF_SIZE);
|
||||
rtlpriv->sec.pairwise_key = NULL;
|
||||
}
|
||||
|
||||
static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no,
|
||||
u8 *mac_addr, u8 *key_cont_128, u16 us_config)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
u32 target_command;
|
||||
u32 target_content = 0;
|
||||
int entry_i;
|
||||
|
||||
RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_DMESG, "Key content :",
|
||||
key_cont_128, 16);
|
||||
|
||||
/* 0-1 config + mac, 2-5 fill 128key,6-7 are reserved */
|
||||
for (entry_i = CAM_CONTENT_COUNT - 1; entry_i >= 0; entry_i--) {
|
||||
target_command = entry_i + CAM_CONTENT_COUNT * entry_no;
|
||||
target_command = target_command | BIT(31) | BIT(16);
|
||||
|
||||
if (entry_i == 0) {
|
||||
target_content = (u32)(*(mac_addr + 0)) << 16 |
|
||||
(u32)(*(mac_addr + 1)) << 24 |
|
||||
(u32)us_config;
|
||||
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI],
|
||||
target_content);
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
|
||||
target_command);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"WRITE %x: %x\n",
|
||||
rtlpriv->cfg->maps[WCAMI], target_content);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"The Key ID is %d\n", entry_no);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"WRITE %x: %x\n",
|
||||
rtlpriv->cfg->maps[RWCAM], target_command);
|
||||
|
||||
} else if (entry_i == 1) {
|
||||
target_content = (u32)(*(mac_addr + 5)) << 24 |
|
||||
(u32)(*(mac_addr + 4)) << 16 |
|
||||
(u32)(*(mac_addr + 3)) << 8 |
|
||||
(u32)(*(mac_addr + 2));
|
||||
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI],
|
||||
target_content);
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
|
||||
target_command);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"WRITE A4: %x\n", target_content);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"WRITE A0: %x\n", target_command);
|
||||
} else {
|
||||
target_content =
|
||||
(u32)(*(key_cont_128 + (entry_i * 4 - 8) + 3)) <<
|
||||
24 | (u32)(*(key_cont_128 + (entry_i * 4 - 8) + 2))
|
||||
<< 16 |
|
||||
(u32)(*(key_cont_128 + (entry_i * 4 - 8) + 1)) << 8
|
||||
| (u32)(*(key_cont_128 + (entry_i * 4 - 8) + 0));
|
||||
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI],
|
||||
target_content);
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
|
||||
target_command);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"WRITE A4: %x\n", target_content);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"WRITE A0: %x\n", target_command);
|
||||
}
|
||||
}
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"after set key, usconfig:%x\n", us_config);
|
||||
}
|
||||
|
||||
u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr,
|
||||
u32 ul_key_id, u32 ul_entry_idx, u32 ul_enc_alg,
|
||||
u32 ul_default_key, u8 *key_content)
|
||||
{
|
||||
u32 us_config;
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
|
||||
"EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, ulUseDK=%x MacAddr %pM\n",
|
||||
ul_entry_idx, ul_key_id, ul_enc_alg,
|
||||
ul_default_key, mac_addr);
|
||||
|
||||
if (ul_key_id == TOTAL_CAM_ENTRY) {
|
||||
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
|
||||
"ulKeyId exceed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ul_default_key == 1)
|
||||
us_config = CFG_VALID | ((u16)(ul_enc_alg) << 2);
|
||||
else
|
||||
us_config = CFG_VALID | ((ul_enc_alg) << 2) | ul_key_id;
|
||||
|
||||
rtl_cam_program_entry(hw, ul_entry_idx, mac_addr,
|
||||
(u8 *)key_content, us_config);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "end\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rtl_cam_delete_one_entry(struct ieee80211_hw *hw,
|
||||
u8 *mac_addr, u32 ul_key_id)
|
||||
{
|
||||
u32 ul_command;
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "key_idx:%d\n", ul_key_id);
|
||||
|
||||
ul_command = ul_key_id * CAM_CONTENT_COUNT;
|
||||
ul_command = ul_command | BIT(31) | BIT(16);
|
||||
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], 0);
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
|
||||
"%s(): WRITE A4: %x\n", __func__, 0);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
|
||||
"%s(): WRITE A0: %x\n", __func__, ul_command);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtl_cam_reset_all_entry(struct ieee80211_hw *hw)
|
||||
{
|
||||
u32 ul_command;
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
ul_command = BIT(31) | BIT(30);
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
|
||||
}
|
||||
|
||||
void rtl_cam_mark_invalid(struct ieee80211_hw *hw, u8 uc_index)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
u32 ul_command;
|
||||
u32 ul_content;
|
||||
u32 ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_AES];
|
||||
|
||||
switch (rtlpriv->sec.pairwise_enc_algorithm) {
|
||||
case WEP40_ENCRYPTION:
|
||||
ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_WEP40];
|
||||
break;
|
||||
case WEP104_ENCRYPTION:
|
||||
ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_WEP104];
|
||||
break;
|
||||
case TKIP_ENCRYPTION:
|
||||
ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_TKIP];
|
||||
break;
|
||||
case AESCCMP_ENCRYPTION:
|
||||
ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_AES];
|
||||
break;
|
||||
default:
|
||||
ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_AES];
|
||||
}
|
||||
|
||||
ul_content = (uc_index & 3) | ((u16)(ul_enc_algo) << 2);
|
||||
|
||||
ul_content |= BIT(15);
|
||||
ul_command = CAM_CONTENT_COUNT * uc_index;
|
||||
ul_command = ul_command | BIT(31) | BIT(16);
|
||||
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], ul_content);
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
|
||||
"%s(): WRITE A4: %x\n", __func__, ul_content);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
|
||||
"%s(): WRITE A0: %x\n", __func__, ul_command);
|
||||
}
|
||||
|
||||
void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
u32 ul_command;
|
||||
u32 ul_content;
|
||||
u32 ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES];
|
||||
u8 entry_i;
|
||||
|
||||
switch (rtlpriv->sec.pairwise_enc_algorithm) {
|
||||
case WEP40_ENCRYPTION:
|
||||
ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_WEP40];
|
||||
break;
|
||||
case WEP104_ENCRYPTION:
|
||||
ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_WEP104];
|
||||
break;
|
||||
case TKIP_ENCRYPTION:
|
||||
ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_TKIP];
|
||||
break;
|
||||
case AESCCMP_ENCRYPTION:
|
||||
ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES];
|
||||
break;
|
||||
default:
|
||||
ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES];
|
||||
}
|
||||
|
||||
for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
|
||||
if (entry_i == 0) {
|
||||
ul_content =
|
||||
(uc_index & 0x03) | ((u16)(ul_encalgo) << 2);
|
||||
ul_content |= BIT(15);
|
||||
} else {
|
||||
ul_content = 0;
|
||||
}
|
||||
|
||||
ul_command = CAM_CONTENT_COUNT * uc_index + entry_i;
|
||||
ul_command = ul_command | BIT(31) | BIT(16);
|
||||
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], ul_content);
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"%s(): WRITE A4: %x\n", __func__, ul_content);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
|
||||
"%s(): WRITE A0: %x\n", __func__, ul_command);
|
||||
}
|
||||
}
|
||||
|
||||
u8 rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
u32 bitmap = (rtlpriv->sec.hwsec_cam_bitmap) >> 4;
|
||||
u8 entry_idx = 0;
|
||||
u8 i, *addr;
|
||||
|
||||
if (!sta_addr) {
|
||||
pr_err("sta_addr is NULL.\n");
|
||||
return TOTAL_CAM_ENTRY;
|
||||
}
|
||||
/* Does STA already exist? */
|
||||
for (i = 4; i < TOTAL_CAM_ENTRY; i++) {
|
||||
addr = rtlpriv->sec.hwsec_cam_sta_addr[i];
|
||||
if (ether_addr_equal_unaligned(addr, sta_addr))
|
||||
return i;
|
||||
}
|
||||
/* Get a free CAM entry. */
|
||||
for (entry_idx = 4; entry_idx < TOTAL_CAM_ENTRY; entry_idx++) {
|
||||
if ((bitmap & BIT(0)) == 0) {
|
||||
pr_err("-----hwsec_cam_bitmap: 0x%x entry_idx=%d\n",
|
||||
rtlpriv->sec.hwsec_cam_bitmap, entry_idx);
|
||||
rtlpriv->sec.hwsec_cam_bitmap |= BIT(0) << entry_idx;
|
||||
memcpy(rtlpriv->sec.hwsec_cam_sta_addr[entry_idx],
|
||||
sta_addr, ETH_ALEN);
|
||||
return entry_idx;
|
||||
}
|
||||
bitmap = bitmap >> 1;
|
||||
}
|
||||
return TOTAL_CAM_ENTRY;
|
||||
}
|
||||
|
||||
void rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
u32 bitmap;
|
||||
u8 i, *addr;
|
||||
|
||||
if (!sta_addr) {
|
||||
pr_err("sta_addr is NULL.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_zero_ether_addr(sta_addr)) {
|
||||
pr_err("sta_addr is %pM\n", sta_addr);
|
||||
return;
|
||||
}
|
||||
/* Does STA already exist? */
|
||||
for (i = 4; i < TOTAL_CAM_ENTRY; i++) {
|
||||
addr = rtlpriv->sec.hwsec_cam_sta_addr[i];
|
||||
bitmap = (rtlpriv->sec.hwsec_cam_bitmap) >> i;
|
||||
if (((bitmap & BIT(0)) == BIT(0)) &&
|
||||
(ether_addr_equal_unaligned(addr, sta_addr))) {
|
||||
/* Remove from HW Security CAM */
|
||||
eth_zero_addr(rtlpriv->sec.hwsec_cam_sta_addr[i]);
|
||||
rtlpriv->sec.hwsec_cam_bitmap &= ~(BIT(0) << i);
|
||||
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
|
||||
"&&&&&&&&&del entry %d\n", i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_CAM_H_
|
||||
#define __RTL_CAM_H_
|
||||
|
||||
#define CAM_CONTENT_COUNT 8
|
||||
|
||||
#define CFG_VALID BIT(15)
|
||||
|
||||
#define PAIRWISE_KEYIDX 0
|
||||
#define CAM_PAIRWISE_KEY_POSITION 4
|
||||
|
||||
#define CAM_CONFIG_NO_USEDK 0
|
||||
|
||||
void rtl_cam_reset_all_entry(struct ieee80211_hw *hw);
|
||||
u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr,
|
||||
u32 ul_key_id, u32 ul_entry_idx, u32 ul_enc_alg,
|
||||
u32 ul_default_key, u8 *key_content);
|
||||
int rtl_cam_delete_one_entry(struct ieee80211_hw *hw, u8 *mac_addr,
|
||||
u32 ul_key_id);
|
||||
void rtl_cam_mark_invalid(struct ieee80211_hw *hw, u8 uc_index);
|
||||
void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index);
|
||||
void rtl_cam_reset_sec_info(struct ieee80211_hw *hw);
|
||||
u8 rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr);
|
||||
void rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr);
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,86 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_CORE_H__
|
||||
#define __RTL_CORE_H__
|
||||
|
||||
#define RTL_SUPPORTED_FILTERS \
|
||||
(FIF_ALLMULTI | FIF_CONTROL | \
|
||||
FIF_OTHER_BSS | \
|
||||
FIF_FCSFAIL | \
|
||||
FIF_BCN_PRBRESP_PROMISC)
|
||||
|
||||
#define DM_DIG_THRESH_HIGH 40
|
||||
#define DM_DIG_THRESH_LOW 35
|
||||
#define DM_FALSEALARM_THRESH_LOW 400
|
||||
#define DM_FALSEALARM_THRESH_HIGH 1000
|
||||
|
||||
#define DM_DIG_MAX 0x3e
|
||||
#define DM_DIG_MIN 0x1e
|
||||
#define DM_DIG_MAX_AP 0x32
|
||||
#define DM_DIG_BACKOFF_MAX 12
|
||||
#define DM_DIG_BACKOFF_MIN -4
|
||||
#define DM_DIG_BACKOFF_DEFAULT 10
|
||||
|
||||
enum cck_packet_detection_threshold {
|
||||
CCK_PD_STAGE_LOWRSSI = 0,
|
||||
CCK_PD_STAGE_HIGHRSSI = 1,
|
||||
CCK_FA_STAGE_LOW = 2,
|
||||
CCK_FA_STAGE_HIGH = 3,
|
||||
CCK_PD_STAGE_MAX = 4,
|
||||
};
|
||||
|
||||
enum dm_dig_ext_port_alg_e {
|
||||
DIG_EXT_PORT_STAGE_0 = 0,
|
||||
DIG_EXT_PORT_STAGE_1 = 1,
|
||||
DIG_EXT_PORT_STAGE_2 = 2,
|
||||
DIG_EXT_PORT_STAGE_3 = 3,
|
||||
DIG_EXT_PORT_STAGE_MAX = 4,
|
||||
};
|
||||
|
||||
enum dm_dig_connect_e {
|
||||
DIG_STA_DISCONNECT,
|
||||
DIG_STA_CONNECT,
|
||||
DIG_STA_BEFORE_CONNECT,
|
||||
DIG_MULTISTA_DISCONNECT,
|
||||
DIG_MULTISTA_CONNECT,
|
||||
DIG_AP_DISCONNECT,
|
||||
DIG_AP_CONNECT,
|
||||
DIG_AP_ADD_STATION,
|
||||
DIG_CONNECT_MAX
|
||||
};
|
||||
|
||||
extern const struct ieee80211_ops rtl_ops;
|
||||
void rtl_fw_cb(const struct firmware *firmware, void *context);
|
||||
void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context);
|
||||
void rtl_addr_delay(u32 addr);
|
||||
void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
|
||||
u32 mask, u32 data);
|
||||
void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data);
|
||||
bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
|
||||
bool rtl_btc_status_false(void);
|
||||
void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,595 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*****************************************************************************/
|
||||
|
||||
#include "wifi.h"
|
||||
#include "cam.h"
|
||||
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/vmalloc.h>
|
||||
|
||||
#ifdef CONFIG_RTLWIFI_DEBUG_ST
|
||||
void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
if (unlikely((comp & rtlpriv->cfg->mod_params->debug_mask) &&
|
||||
(level <= rtlpriv->cfg->mod_params->debug_level))) {
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
|
||||
pr_info(":<%lx> %pV", in_interrupt(), &vaf);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
void _rtl_dbg_print(struct rtl_priv *rtlpriv, u64 comp, int level,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
if (unlikely((comp & rtlpriv->cfg->mod_params->debug_mask) &&
|
||||
(level <= rtlpriv->cfg->mod_params->debug_level))) {
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
|
||||
pr_info("%pV", &vaf);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
void _rtl_dbg_print_data(struct rtl_priv *rtlpriv, u64 comp, int level,
|
||||
const char *titlestring,
|
||||
const void *hexdata, int hexdatalen)
|
||||
{
|
||||
if (unlikely(((comp) & rtlpriv->cfg->mod_params->debug_mask) &&
|
||||
((level) <= rtlpriv->cfg->mod_params->debug_level))) {
|
||||
pr_info("In process \"%s\" (pid %i): %s\n",
|
||||
current->comm, current->pid, titlestring);
|
||||
print_hex_dump_bytes("", DUMP_PREFIX_NONE,
|
||||
hexdata, hexdatalen);
|
||||
}
|
||||
}
|
||||
|
||||
struct rtl_debgufs_priv {
|
||||
struct rtl_priv *rtlpriv;
|
||||
int (*cb)(struct seq_file *m, void *v);
|
||||
u32 cb_data;
|
||||
};
|
||||
|
||||
static struct dentry *debugfs_topdir;
|
||||
|
||||
static int rtl_debug_get_common(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = m->private;
|
||||
|
||||
return debugfs_priv->cb(m, v);
|
||||
}
|
||||
|
||||
static int dl_debug_open_common(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, rtl_debug_get_common, inode->i_private);
|
||||
}
|
||||
|
||||
static const struct file_operations file_ops_common = {
|
||||
.open = dl_debug_open_common,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = seq_release,
|
||||
};
|
||||
|
||||
static int rtl_debug_get_mac_page(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = m->private;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
u32 page = debugfs_priv->cb_data;
|
||||
int i, n;
|
||||
int max = 0xff;
|
||||
|
||||
for (n = 0; n <= max; ) {
|
||||
seq_printf(m, "\n%8.8x ", n + page);
|
||||
for (i = 0; i < 4 && n <= max; i++, n += 4)
|
||||
seq_printf(m, "%8.8x ",
|
||||
rtl_read_dword(rtlpriv, (page | n)));
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RTL_DEBUG_IMPL_MAC_SERIES(page, addr) \
|
||||
struct rtl_debgufs_priv rtl_debug_priv_mac_ ##page = { \
|
||||
.cb = rtl_debug_get_mac_page, \
|
||||
.cb_data = addr, \
|
||||
}
|
||||
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(0, 0x0000);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(1, 0x0100);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(2, 0x0200);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(3, 0x0300);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(4, 0x0400);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(5, 0x0500);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(6, 0x0600);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(7, 0x0700);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(10, 0x1000);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(11, 0x1100);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(12, 0x1200);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(13, 0x1300);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(14, 0x1400);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(15, 0x1500);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(16, 0x1600);
|
||||
RTL_DEBUG_IMPL_MAC_SERIES(17, 0x1700);
|
||||
|
||||
static int rtl_debug_get_bb_page(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = m->private;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
struct ieee80211_hw *hw = rtlpriv->hw;
|
||||
u32 page = debugfs_priv->cb_data;
|
||||
int i, n;
|
||||
int max = 0xff;
|
||||
|
||||
for (n = 0; n <= max; ) {
|
||||
seq_printf(m, "\n%8.8x ", n + page);
|
||||
for (i = 0; i < 4 && n <= max; i++, n += 4)
|
||||
seq_printf(m, "%8.8x ",
|
||||
rtl_get_bbreg(hw, (page | n), 0xffffffff));
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RTL_DEBUG_IMPL_BB_SERIES(page, addr) \
|
||||
struct rtl_debgufs_priv rtl_debug_priv_bb_ ##page = { \
|
||||
.cb = rtl_debug_get_bb_page, \
|
||||
.cb_data = addr, \
|
||||
}
|
||||
|
||||
RTL_DEBUG_IMPL_BB_SERIES(8, 0x0800);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(9, 0x0900);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(a, 0x0a00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(b, 0x0b00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(c, 0x0c00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(d, 0x0d00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(e, 0x0e00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(f, 0x0f00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(18, 0x1800);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(19, 0x1900);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(1a, 0x1a00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(1b, 0x1b00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(1c, 0x1c00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(1d, 0x1d00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(1e, 0x1e00);
|
||||
RTL_DEBUG_IMPL_BB_SERIES(1f, 0x1f00);
|
||||
|
||||
static int rtl_debug_get_reg_rf(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = m->private;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
struct ieee80211_hw *hw = rtlpriv->hw;
|
||||
enum radio_path rfpath = debugfs_priv->cb_data;
|
||||
int i, n;
|
||||
int max = 0x40;
|
||||
|
||||
if (IS_HARDWARE_TYPE_8822B(rtlpriv))
|
||||
max = 0xff;
|
||||
|
||||
seq_printf(m, "\nPATH(%d)", rfpath);
|
||||
|
||||
for (n = 0; n <= max; ) {
|
||||
seq_printf(m, "\n%8.8x ", n);
|
||||
for (i = 0; i < 4 && n <= max; n += 1, i++)
|
||||
seq_printf(m, "%8.8x ",
|
||||
rtl_get_rfreg(hw, rfpath, n, 0xffffffff));
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RTL_DEBUG_IMPL_RF_SERIES(page, addr) \
|
||||
struct rtl_debgufs_priv rtl_debug_priv_rf_ ##page = { \
|
||||
.cb = rtl_debug_get_reg_rf, \
|
||||
.cb_data = addr, \
|
||||
}
|
||||
|
||||
RTL_DEBUG_IMPL_RF_SERIES(a, RF90_PATH_A);
|
||||
RTL_DEBUG_IMPL_RF_SERIES(b, RF90_PATH_B);
|
||||
|
||||
static int rtl_debug_get_cam_register(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = m->private;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
int start = debugfs_priv->cb_data;
|
||||
u32 target_cmd = 0;
|
||||
u32 target_val = 0;
|
||||
u8 entry_i = 0;
|
||||
u32 ulstatus;
|
||||
int i = 100, j = 0;
|
||||
int end = (start + 11 > TOTAL_CAM_ENTRY ? TOTAL_CAM_ENTRY : start + 11);
|
||||
|
||||
/* This dump the current register page */
|
||||
seq_printf(m,
|
||||
"\n#################### SECURITY CAM (%d-%d) ##################\n",
|
||||
start, end - 1);
|
||||
|
||||
for (j = start; j < end; j++) {
|
||||
seq_printf(m, "\nD: %2x > ", j);
|
||||
for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
|
||||
/* polling bit, and No Write enable, and address */
|
||||
target_cmd = entry_i + CAM_CONTENT_COUNT * j;
|
||||
target_cmd = target_cmd | BIT(31);
|
||||
|
||||
/* Check polling bit is clear */
|
||||
while ((i--) >= 0) {
|
||||
ulstatus = rtl_read_dword(
|
||||
rtlpriv,
|
||||
rtlpriv->cfg->maps[RWCAM]);
|
||||
if (ulstatus & BIT(31))
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
|
||||
target_cmd);
|
||||
target_val = rtl_read_dword(rtlpriv,
|
||||
rtlpriv->cfg->maps[RCAMO]);
|
||||
seq_printf(m, "%8.8x ", target_val);
|
||||
}
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RTL_DEBUG_IMPL_CAM_SERIES(page, addr) \
|
||||
struct rtl_debgufs_priv rtl_debug_priv_cam_ ##page = { \
|
||||
.cb = rtl_debug_get_cam_register, \
|
||||
.cb_data = addr, \
|
||||
}
|
||||
|
||||
RTL_DEBUG_IMPL_CAM_SERIES(1, 0);
|
||||
RTL_DEBUG_IMPL_CAM_SERIES(2, 11);
|
||||
RTL_DEBUG_IMPL_CAM_SERIES(3, 22);
|
||||
|
||||
static int rtl_debug_get_btcoex(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = m->private;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
|
||||
if (rtlpriv->cfg->ops->get_btc_status())
|
||||
rtlpriv->btcoexist.btc_ops->btc_display_bt_coex_info(rtlpriv,
|
||||
m);
|
||||
|
||||
seq_puts(m, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rtl_debgufs_priv rtl_debug_priv_btcoex = {
|
||||
.cb = rtl_debug_get_btcoex,
|
||||
.cb_data = 0,
|
||||
};
|
||||
|
||||
static ssize_t rtl_debugfs_set_write_reg(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = filp->private_data;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
struct ieee80211_hw *hw = rtlpriv->hw;
|
||||
char tmp[32 + 1];
|
||||
int tmp_len;
|
||||
u32 addr, val, len;
|
||||
int num;
|
||||
|
||||
if (count < 3) {
|
||||
/*printk("argument size is less than 3\n");*/
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
tmp_len = (count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count);
|
||||
|
||||
if (!buffer || copy_from_user(tmp, buffer, tmp_len))
|
||||
return count;
|
||||
|
||||
tmp[tmp_len] = '\0';
|
||||
|
||||
/* write H2C */
|
||||
if (!strncmp(tmp, "h2c", 3)) {
|
||||
u8 h2c_len, h2c_data_packed[8];
|
||||
int h2c_data[8]; /* idx 0: cmd */
|
||||
int i;
|
||||
|
||||
h2c_len = sscanf(tmp + 3, "%X %X %X %X %X %X %X %X",
|
||||
&h2c_data[0], &h2c_data[1],
|
||||
&h2c_data[2], &h2c_data[3],
|
||||
&h2c_data[4], &h2c_data[5],
|
||||
&h2c_data[6], &h2c_data[7]);
|
||||
|
||||
if (h2c_len <= 0)
|
||||
return count;
|
||||
|
||||
for (i = 0; i < h2c_len; i++)
|
||||
h2c_data_packed[i] = (u8)h2c_data[i];
|
||||
|
||||
rtlpriv->cfg->ops->fill_h2c_cmd(hw, h2c_data_packed[0],
|
||||
h2c_len - 1,
|
||||
&h2c_data_packed[1]);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* write RF register */
|
||||
if (!strncmp(tmp, "rf", 2)) {
|
||||
int path;
|
||||
u32 addr, bitmask, data;
|
||||
|
||||
num = sscanf(tmp + 2, "%X %X %X %X",
|
||||
&path, &addr, &bitmask, &data);
|
||||
|
||||
if (num != 4) {
|
||||
RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
|
||||
"Format is <path> <addr> <mask> <data>\n");
|
||||
return count;
|
||||
}
|
||||
|
||||
rtl_set_rfreg(hw, path, addr, bitmask, data);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* write BB/MAC register */
|
||||
num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
|
||||
|
||||
if (num != 3) {
|
||||
/*printk("invalid write_reg parameter!\n");*/
|
||||
return count;
|
||||
}
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
rtl_write_byte(rtlpriv, addr, (u8)val);
|
||||
break;
|
||||
case 2:
|
||||
rtl_write_word(rtlpriv, addr, (u16)val);
|
||||
break;
|
||||
case 4:
|
||||
rtl_write_dword(rtlpriv, addr, val);
|
||||
break;
|
||||
default:
|
||||
/*printk("error write length=%d", len);*/
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int rtl_debugfs_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
filp->private_data = inode->i_private;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl_debugfs_close(struct inode *inode, struct file *filp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rtl_debgufs_priv rtl_debug_priv_write_reg = {
|
||||
.cb = NULL,
|
||||
.cb_data = 0,
|
||||
};
|
||||
|
||||
static const struct file_operations file_ops_write_reg = {
|
||||
.owner = THIS_MODULE,
|
||||
.write = rtl_debugfs_set_write_reg,
|
||||
.open = rtl_debugfs_open,
|
||||
.release = rtl_debugfs_close,
|
||||
};
|
||||
|
||||
static ssize_t rtl_debugfs_phydm_cmd(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = filp->private_data;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
|
||||
char tmp[64];
|
||||
|
||||
if (!rtlpriv->dbg.msg_buf)
|
||||
return -ENOMEM;
|
||||
|
||||
if (!rtlpriv->phydm.ops)
|
||||
return -EFAULT;
|
||||
|
||||
if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
|
||||
tmp[count] = '\0';
|
||||
|
||||
rtlpriv->phydm.ops->phydm_debug_cmd(rtlpriv, tmp, count,
|
||||
rtlpriv->dbg.msg_buf,
|
||||
80 * 25);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int rtl_debug_get_phydm_cmd(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtl_debgufs_priv *debugfs_priv = m->private;
|
||||
struct rtl_priv *rtlpriv = debugfs_priv->rtlpriv;
|
||||
|
||||
if (rtlpriv->dbg.msg_buf)
|
||||
seq_puts(m, rtlpriv->dbg.msg_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl_debugfs_open_rw(struct inode *inode, struct file *filp)
|
||||
{
|
||||
if (filp->f_mode & FMODE_READ)
|
||||
single_open(filp, rtl_debug_get_phydm_cmd, inode->i_private);
|
||||
else
|
||||
filp->private_data = inode->i_private;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl_debugfs_close_rw(struct inode *inode, struct file *filp)
|
||||
{
|
||||
if (filp->f_mode == FMODE_READ)
|
||||
seq_release(inode, filp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rtl_debgufs_priv rtl_debug_priv_phydm_cmd = {
|
||||
.cb = NULL,
|
||||
.cb_data = 0,
|
||||
};
|
||||
|
||||
static const struct file_operations file_ops_phydm_cmd = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = rtl_debugfs_open_rw,
|
||||
.release = rtl_debugfs_close_rw,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.write = rtl_debugfs_phydm_cmd,
|
||||
};
|
||||
|
||||
#define RTL_DEBUGFS_ADD_CORE(name, mode, fopname) \
|
||||
do { \
|
||||
rtl_debug_priv_ ##name.rtlpriv = rtlpriv; \
|
||||
if (!debugfs_create_file(#name, mode, \
|
||||
parent, &rtl_debug_priv_ ##name, \
|
||||
&file_ops_ ##fopname)) \
|
||||
pr_err("Unable to initialize debugfs:%s/%s\n", \
|
||||
rtlpriv->dbg.debugfs_name, \
|
||||
#name); \
|
||||
} while (0)
|
||||
|
||||
#define RTL_DEBUGFS_ADD(name) \
|
||||
RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0444, common)
|
||||
#define RTL_DEBUGFS_ADD_W(name) \
|
||||
RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0222, write_reg)
|
||||
#define RTL_DEBUGFS_ADD_RW(name) \
|
||||
RTL_DEBUGFS_ADD_CORE(name, S_IFREG | 0666, phydm_cmd)
|
||||
|
||||
void rtl_debug_add_one(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
|
||||
struct dentry *parent;
|
||||
|
||||
rtlpriv->dbg.msg_buf = vzalloc(80 * 25);
|
||||
|
||||
snprintf(rtlpriv->dbg.debugfs_name, 18, "%02x-%02x-%02x-%02x-%02x-%02x",
|
||||
rtlefuse->dev_addr[0], rtlefuse->dev_addr[1],
|
||||
rtlefuse->dev_addr[2], rtlefuse->dev_addr[3],
|
||||
rtlefuse->dev_addr[4], rtlefuse->dev_addr[5]);
|
||||
|
||||
rtlpriv->dbg.debugfs_dir =
|
||||
debugfs_create_dir(rtlpriv->dbg.debugfs_name, debugfs_topdir);
|
||||
if (!rtlpriv->dbg.debugfs_dir) {
|
||||
pr_err("Unable to init debugfs:/%s/%s\n", rtlpriv->cfg->name,
|
||||
rtlpriv->dbg.debugfs_name);
|
||||
return;
|
||||
}
|
||||
|
||||
parent = rtlpriv->dbg.debugfs_dir;
|
||||
|
||||
RTL_DEBUGFS_ADD(mac_0);
|
||||
RTL_DEBUGFS_ADD(mac_1);
|
||||
RTL_DEBUGFS_ADD(mac_2);
|
||||
RTL_DEBUGFS_ADD(mac_3);
|
||||
RTL_DEBUGFS_ADD(mac_4);
|
||||
RTL_DEBUGFS_ADD(mac_5);
|
||||
RTL_DEBUGFS_ADD(mac_6);
|
||||
RTL_DEBUGFS_ADD(mac_7);
|
||||
RTL_DEBUGFS_ADD(bb_8);
|
||||
RTL_DEBUGFS_ADD(bb_9);
|
||||
RTL_DEBUGFS_ADD(bb_a);
|
||||
RTL_DEBUGFS_ADD(bb_b);
|
||||
RTL_DEBUGFS_ADD(bb_c);
|
||||
RTL_DEBUGFS_ADD(bb_d);
|
||||
RTL_DEBUGFS_ADD(bb_e);
|
||||
RTL_DEBUGFS_ADD(bb_f);
|
||||
RTL_DEBUGFS_ADD(mac_10);
|
||||
RTL_DEBUGFS_ADD(mac_11);
|
||||
RTL_DEBUGFS_ADD(mac_12);
|
||||
RTL_DEBUGFS_ADD(mac_13);
|
||||
RTL_DEBUGFS_ADD(mac_14);
|
||||
RTL_DEBUGFS_ADD(mac_15);
|
||||
RTL_DEBUGFS_ADD(mac_16);
|
||||
RTL_DEBUGFS_ADD(mac_17);
|
||||
RTL_DEBUGFS_ADD(bb_18);
|
||||
RTL_DEBUGFS_ADD(bb_19);
|
||||
RTL_DEBUGFS_ADD(bb_1a);
|
||||
RTL_DEBUGFS_ADD(bb_1b);
|
||||
RTL_DEBUGFS_ADD(bb_1c);
|
||||
RTL_DEBUGFS_ADD(bb_1d);
|
||||
RTL_DEBUGFS_ADD(bb_1e);
|
||||
RTL_DEBUGFS_ADD(bb_1f);
|
||||
RTL_DEBUGFS_ADD(rf_a);
|
||||
RTL_DEBUGFS_ADD(rf_b);
|
||||
|
||||
RTL_DEBUGFS_ADD(cam_1);
|
||||
RTL_DEBUGFS_ADD(cam_2);
|
||||
RTL_DEBUGFS_ADD(cam_3);
|
||||
|
||||
RTL_DEBUGFS_ADD(btcoex);
|
||||
|
||||
RTL_DEBUGFS_ADD_W(write_reg);
|
||||
|
||||
RTL_DEBUGFS_ADD_RW(phydm_cmd);
|
||||
}
|
||||
|
||||
void rtl_debug_remove_one(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
debugfs_remove_recursive(rtlpriv->dbg.debugfs_dir);
|
||||
rtlpriv->dbg.debugfs_dir = NULL;
|
||||
|
||||
vfree(rtlpriv->dbg.msg_buf);
|
||||
}
|
||||
|
||||
void rtl_debugfs_add_topdir(void)
|
||||
{
|
||||
debugfs_topdir = debugfs_create_dir("rtlwifi", NULL);
|
||||
}
|
||||
|
||||
void rtl_debugfs_remove_topdir(void)
|
||||
{
|
||||
debugfs_remove_recursive(debugfs_topdir);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,234 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_DEBUG_H__
|
||||
#define __RTL_DEBUG_H__
|
||||
|
||||
/*--------------------------------------------------------------
|
||||
* Debug level
|
||||
*------------------------------------------------------------
|
||||
*
|
||||
*Fatal bug.
|
||||
*For example, Tx/Rx/IO locked up,
|
||||
*memory access violation,
|
||||
*resource allocation failed,
|
||||
*unexpected HW behavior, HW BUG
|
||||
*and so on.
|
||||
*/
|
||||
/*#define DBG_EMERG 0 */
|
||||
|
||||
/*Abnormal, rare, or unexpected cases.
|
||||
*For example, Packet/IO Ctl canceled,
|
||||
*device surprisingly removed and so on.
|
||||
*/
|
||||
#define DBG_WARNING 2
|
||||
|
||||
/*Normal case driver developer should
|
||||
*open, we can see link status like
|
||||
*assoc/AddBA/DHCP/adapter start and
|
||||
*so on basic and useful infromations.
|
||||
*/
|
||||
#define DBG_DMESG 3
|
||||
|
||||
/*Normal case with useful information
|
||||
*about current SW or HW state.
|
||||
*For example, Tx/Rx descriptor to fill,
|
||||
*Tx/Rx descriptor completed status,
|
||||
*SW protocol state change, dynamic
|
||||
*mechanism state change and so on.
|
||||
*/
|
||||
#define DBG_LOUD 4
|
||||
|
||||
/*Normal case with detail execution
|
||||
*flow or information.
|
||||
*/
|
||||
#define DBG_TRACE 5
|
||||
|
||||
/*--------------------------------------------------------------
|
||||
* Define the rt_trace components
|
||||
*--------------------------------------------------------------
|
||||
*/
|
||||
#define COMP_ERR BIT(0)
|
||||
#define COMP_FW BIT(1)
|
||||
#define COMP_INIT BIT(2) /*For init/deinit */
|
||||
#define COMP_RECV BIT(3) /*For Rx. */
|
||||
#define COMP_SEND BIT(4) /*For Tx. */
|
||||
#define COMP_MLME BIT(5) /*For MLME. */
|
||||
#define COMP_SCAN BIT(6) /*For Scan. */
|
||||
#define COMP_INTR BIT(7) /*For interrupt Related. */
|
||||
#define COMP_LED BIT(8) /*For LED. */
|
||||
#define COMP_SEC BIT(9) /*For sec. */
|
||||
#define COMP_BEACON BIT(10) /*For beacon. */
|
||||
#define COMP_RATE BIT(11) /*For rate. */
|
||||
#define COMP_RXDESC BIT(12) /*For rx desc. */
|
||||
#define COMP_DIG BIT(13) /*For DIG */
|
||||
#define COMP_TXAGC BIT(14) /*For Tx power */
|
||||
#define COMP_HIPWR BIT(15) /*For High Power Mechanism */
|
||||
#define COMP_POWER BIT(16) /*For lps/ips/aspm. */
|
||||
#define COMP_POWER_TRACKING BIT(17) /*For TX POWER TRACKING */
|
||||
#define COMP_BB_POWERSAVING BIT(18)
|
||||
#define COMP_SWAS BIT(19) /*For SW Antenna Switch */
|
||||
#define COMP_RF BIT(20) /*For RF. */
|
||||
#define COMP_TURBO BIT(21) /*For EDCA TURBO. */
|
||||
#define COMP_RATR BIT(22)
|
||||
#define COMP_CMD BIT(23)
|
||||
#define COMP_EFUSE BIT(24)
|
||||
#define COMP_QOS BIT(25)
|
||||
#define COMP_MAC80211 BIT(26)
|
||||
#define COMP_REGD BIT(27)
|
||||
#define COMP_CHAN BIT(28)
|
||||
#define COMP_USB BIT(29)
|
||||
#define COMP_EASY_CONCURRENT COMP_USB /* reuse of this bit is OK */
|
||||
#define COMP_BT_COEXIST BIT(30)
|
||||
#define COMP_IQK BIT(31)
|
||||
#define COMP_TX_REPORT BIT_ULL(32)
|
||||
#define COMP_HALMAC BIT_ULL(34)
|
||||
#define COMP_PHYDM BIT_ULL(35)
|
||||
|
||||
/*--------------------------------------------------------------
|
||||
* Define the rt_print components
|
||||
*--------------------------------------------------------------
|
||||
*/
|
||||
/* Define EEPROM and EFUSE check module bit*/
|
||||
#define EEPROM_W BIT(0)
|
||||
#define EFUSE_PG BIT(1)
|
||||
#define EFUSE_READ_ALL BIT(2)
|
||||
|
||||
/* Define init check for module bit*/
|
||||
#define INIT_EEPROM BIT(0)
|
||||
#define INIT_TXPOWER BIT(1)
|
||||
#define INIT_IQK BIT(2)
|
||||
#define INIT_RF BIT(3)
|
||||
|
||||
/* Define PHY-BB/RF/MAC check module bit */
|
||||
#define PHY_BBR BIT(0)
|
||||
#define PHY_BBW BIT(1)
|
||||
#define PHY_RFR BIT(2)
|
||||
#define PHY_RFW BIT(3)
|
||||
#define PHY_MACR BIT(4)
|
||||
#define PHY_MACW BIT(5)
|
||||
#define PHY_ALLR BIT(6)
|
||||
#define PHY_ALLW BIT(7)
|
||||
#define PHY_TXPWR BIT(8)
|
||||
#define PHY_PWRDIFF BIT(9)
|
||||
|
||||
/* Define Dynamic Mechanism check module bit --> FDM */
|
||||
#define WA_IOT BIT(0)
|
||||
#define DM_PWDB BIT(1)
|
||||
#define DM_MONITOR BIT(2)
|
||||
#define DM_DIG BIT(3)
|
||||
#define DM_EDCA_TURBO BIT(4)
|
||||
|
||||
#define DM_PWDB BIT(1)
|
||||
|
||||
enum dbgp_flag_e {
|
||||
FQOS = 0,
|
||||
FTX = 1,
|
||||
FRX = 2,
|
||||
FSEC = 3,
|
||||
FMGNT = 4,
|
||||
FMLME = 5,
|
||||
FRESOURCE = 6,
|
||||
FBEACON = 7,
|
||||
FISR = 8,
|
||||
FPHY = 9,
|
||||
FMP = 10,
|
||||
FEEPROM = 11,
|
||||
FPWR = 12,
|
||||
FDM = 13,
|
||||
FDBGCTRL = 14,
|
||||
FC2H = 15,
|
||||
FBT = 16,
|
||||
FINIT = 17,
|
||||
FIOCTL = 18,
|
||||
DBGP_TYPE_MAX
|
||||
};
|
||||
|
||||
#ifdef CONFIG_RTLWIFI_DEBUG_ST
|
||||
|
||||
struct rtl_priv;
|
||||
|
||||
__printf(4, 5)
|
||||
void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
|
||||
const char *fmt, ...);
|
||||
|
||||
__printf(4, 5)
|
||||
void _rtl_dbg_print(struct rtl_priv *rtlpriv, u64 comp, int level,
|
||||
const char *fmt, ...);
|
||||
|
||||
void _rtl_dbg_print_data(struct rtl_priv *rtlpriv, u64 comp, int level,
|
||||
const char *titlestring,
|
||||
const void *hexdata, int hexdatalen);
|
||||
|
||||
#define RT_TRACE(rtlpriv, comp, level, fmt, ...) \
|
||||
_rtl_dbg_trace(rtlpriv, comp, level, \
|
||||
fmt, ##__VA_ARGS__)
|
||||
|
||||
#define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \
|
||||
_rtl_dbg_print(rtlpriv, dbgtype, dbgflag, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \
|
||||
_hexdatalen) \
|
||||
_rtl_dbg_print_data(rtlpriv, _comp, _level, \
|
||||
_titlestring, _hexdata, _hexdatalen)
|
||||
|
||||
#else
|
||||
|
||||
struct rtl_priv;
|
||||
|
||||
__printf(4, 5)
|
||||
static inline void RT_TRACE(struct rtl_priv *rtlpriv,
|
||||
u64 comp, int level,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
|
||||
__printf(4, 5)
|
||||
static inline void RTPRINT(struct rtl_priv *rtlpriv,
|
||||
int dbgtype, int dbgflag,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
|
||||
u64 comp, int level,
|
||||
const char *titlestring,
|
||||
const void *hexdata, size_t hexdatalen)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTLWIFI_DEBUG_ST
|
||||
void rtl_debug_add_one(struct ieee80211_hw *hw);
|
||||
void rtl_debug_remove_one(struct ieee80211_hw *hw);
|
||||
void rtl_debugfs_add_topdir(void);
|
||||
void rtl_debugfs_remove_topdir(void);
|
||||
#else
|
||||
#define rtl_debug_add_one(hw)
|
||||
#define rtl_debug_remove_one(hw)
|
||||
#define rtl_debugfs_add_topdir()
|
||||
#define rtl_debugfs_remove_topdir()
|
||||
#endif
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,120 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_EFUSE_H_
|
||||
#define __RTL_EFUSE_H_
|
||||
|
||||
#define EFUSE_IC_ID_OFFSET 506
|
||||
|
||||
#define EFUSE_MAX_WORD_UNIT 4
|
||||
|
||||
#define EFUSE_INIT_MAP 0
|
||||
#define EFUSE_MODIFY_MAP 1
|
||||
|
||||
#define PG_STATE_HEADER 0x01
|
||||
#define PG_STATE_WORD_0 0x02
|
||||
#define PG_STATE_WORD_1 0x04
|
||||
#define PG_STATE_WORD_2 0x08
|
||||
#define PG_STATE_WORD_3 0x10
|
||||
#define PG_STATE_DATA 0x20
|
||||
|
||||
#define EFUSE_REPEAT_THRESHOLD_ 3
|
||||
#define EFUSE_ERROE_HANDLE 1
|
||||
|
||||
struct efuse_map {
|
||||
u8 offset;
|
||||
u8 word_start;
|
||||
u8 byte_start;
|
||||
u8 byte_cnts;
|
||||
};
|
||||
|
||||
struct pgpkt_struct {
|
||||
u8 offset;
|
||||
u8 word_en;
|
||||
u8 data[8];
|
||||
};
|
||||
|
||||
enum efuse_data_item {
|
||||
EFUSE_CHIP_ID = 0,
|
||||
EFUSE_LDO_SETTING,
|
||||
EFUSE_CLK_SETTING,
|
||||
EFUSE_SDIO_SETTING,
|
||||
EFUSE_CCCR,
|
||||
EFUSE_SDIO_MODE,
|
||||
EFUSE_OCR,
|
||||
EFUSE_F0CIS,
|
||||
EFUSE_F1CIS,
|
||||
EFUSE_MAC_ADDR,
|
||||
EFUSE_EEPROM_VER,
|
||||
EFUSE_CHAN_PLAN,
|
||||
EFUSE_TXPW_TAB
|
||||
};
|
||||
|
||||
enum {
|
||||
VOLTAGE_V25 = 0x03,
|
||||
LDOE25_SHIFT = 28,
|
||||
};
|
||||
|
||||
struct efuse_priv {
|
||||
u8 id[2];
|
||||
u8 ldo_setting[2];
|
||||
u8 clk_setting[2];
|
||||
u8 cccr;
|
||||
u8 sdio_mode;
|
||||
u8 ocr[3];
|
||||
u8 cis0[17];
|
||||
u8 cis1[48];
|
||||
u8 mac_addr[6];
|
||||
u8 eeprom_verno;
|
||||
u8 channel_plan;
|
||||
u8 tx_power_b[14];
|
||||
u8 tx_power_g[14];
|
||||
};
|
||||
|
||||
void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
|
||||
void efuse_initialize(struct ieee80211_hw *hw);
|
||||
u8 efuse_read_1byte(struct ieee80211_hw *hw, u16 address);
|
||||
int efuse_one_byte_read(struct ieee80211_hw *hw, u16 addr, u8 *data);
|
||||
void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value);
|
||||
void read_efuse(struct ieee80211_hw *hw, u16 _offset,
|
||||
u16 _size_byte, u8 *pbuf);
|
||||
void efuse_shadow_read(struct ieee80211_hw *hw, u8 type,
|
||||
u16 offset, u32 *value);
|
||||
void efuse_shadow_write(struct ieee80211_hw *hw, u8 type,
|
||||
u16 offset, u32 value);
|
||||
bool efuse_shadow_update(struct ieee80211_hw *hw);
|
||||
bool efuse_shadow_update_chk(struct ieee80211_hw *hw);
|
||||
void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw);
|
||||
void efuse_force_write_vendor_id(struct ieee80211_hw *hw);
|
||||
void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx);
|
||||
void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate);
|
||||
int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv,
|
||||
int max_size, u8 *hwinfo, int *params);
|
||||
void rtl_fill_dummy(u8 *pfwbuf, u32 *pfwlen);
|
||||
void rtl_fw_page_write(struct ieee80211_hw *hw, u32 page, const u8 *buffer,
|
||||
u32 size);
|
||||
void rtl_fw_block_write(struct ieee80211_hw *hw, const u8 *buffer, u32 size);
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,329 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_PCI_H__
|
||||
#define __RTL_PCI_H__
|
||||
|
||||
#include <linux/pci.h>
|
||||
/* 1: MSDU packet queue,
|
||||
* 2: Rx Command Queue
|
||||
*/
|
||||
#define RTL_PCI_RX_MPDU_QUEUE 0
|
||||
#define RTL_PCI_RX_CMD_QUEUE 1
|
||||
#define RTL_PCI_MAX_RX_QUEUE 2
|
||||
|
||||
#define RTL_PCI_MAX_RX_COUNT 512/*64*/
|
||||
#define RTL_PCI_MAX_TX_QUEUE_COUNT 9
|
||||
|
||||
#define RT_TXDESC_NUM 128
|
||||
#define TX_DESC_NUM_92E 512
|
||||
#define TX_DESC_NUM_8822B 512
|
||||
#define RT_TXDESC_NUM_BE_QUEUE 256
|
||||
|
||||
#define BK_QUEUE 0
|
||||
#define BE_QUEUE 1
|
||||
#define VI_QUEUE 2
|
||||
#define VO_QUEUE 3
|
||||
#define BEACON_QUEUE 4
|
||||
#define TXCMD_QUEUE 5
|
||||
#define MGNT_QUEUE 6
|
||||
#define HIGH_QUEUE 7
|
||||
#define HCCA_QUEUE 8
|
||||
#define H2C_QUEUE TXCMD_QUEUE /* In 8822B */
|
||||
|
||||
#define RTL_PCI_DEVICE(vend, dev, cfg) \
|
||||
.vendor = (vend), \
|
||||
.device = (dev), \
|
||||
.subvendor = PCI_ANY_ID, \
|
||||
.subdevice = PCI_ANY_ID,\
|
||||
.driver_data = (kernel_ulong_t)&(cfg)
|
||||
|
||||
#define INTEL_VENDOR_ID 0x8086
|
||||
#define SIS_VENDOR_ID 0x1039
|
||||
#define ATI_VENDOR_ID 0x1002
|
||||
#define ATI_DEVICE_ID 0x7914
|
||||
#define AMD_VENDOR_ID 0x1022
|
||||
|
||||
#define PCI_MAX_BRIDGE_NUMBER 255
|
||||
#define PCI_MAX_DEVICES 32
|
||||
#define PCI_MAX_FUNCTION 8
|
||||
|
||||
#define PCI_CONF_ADDRESS 0x0CF8 /*PCI Configuration Space Address */
|
||||
#define PCI_CONF_DATA 0x0CFC /*PCI Configuration Space Data */
|
||||
|
||||
#define PCI_CLASS_BRIDGE_DEV 0x06
|
||||
#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
|
||||
#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10
|
||||
#define PCI_CAP_ID_EXP 0x10
|
||||
|
||||
#define U1DONTCARE 0xFF
|
||||
#define U2DONTCARE 0xFFFF
|
||||
#define U4DONTCARE 0xFFFFFFFF
|
||||
|
||||
#define RTL_PCI_8192_DID 0x8192 /*8192 PCI-E */
|
||||
#define RTL_PCI_8192SE_DID 0x8192 /*8192 SE */
|
||||
#define RTL_PCI_8174_DID 0x8174 /*8192 SE */
|
||||
#define RTL_PCI_8173_DID 0x8173 /*8191 SE Crab */
|
||||
#define RTL_PCI_8172_DID 0x8172 /*8191 SE RE */
|
||||
#define RTL_PCI_8171_DID 0x8171 /*8191 SE Unicron */
|
||||
#define RTL_PCI_8723AE_DID 0x8723 /*8723AE */
|
||||
#define RTL_PCI_0045_DID 0x0045 /*8190 PCI for Ceraga */
|
||||
#define RTL_PCI_0046_DID 0x0046 /*8190 Cardbus for Ceraga */
|
||||
#define RTL_PCI_0044_DID 0x0044 /*8192e PCIE for Ceraga */
|
||||
#define RTL_PCI_0047_DID 0x0047 /*8192e Express Card for Ceraga */
|
||||
#define RTL_PCI_700F_DID 0x700F
|
||||
#define RTL_PCI_701F_DID 0x701F
|
||||
#define RTL_PCI_DLINK_DID 0x3304
|
||||
#define RTL_PCI_8723AE_DID 0x8723 /*8723e */
|
||||
#define RTL_PCI_8192CET_DID 0x8191 /*8192ce */
|
||||
#define RTL_PCI_8192CE_DID 0x8178 /*8192ce */
|
||||
#define RTL_PCI_8191CE_DID 0x8177 /*8192ce */
|
||||
#define RTL_PCI_8188CE_DID 0x8176 /*8192ce */
|
||||
#define RTL_PCI_8192CU_DID 0x8191 /*8192ce */
|
||||
#define RTL_PCI_8192DE_DID 0x8193 /*8192de */
|
||||
#define RTL_PCI_8192DE_DID2 0x002B /*92DE*/
|
||||
#define RTL_PCI_8188EE_DID 0x8179 /*8188ee*/
|
||||
#define RTL_PCI_8723BE_DID 0xB723 /*8723be*/
|
||||
#define RTL_PCI_8192EE_DID 0x818B /*8192ee*/
|
||||
#define RTL_PCI_8821AE_DID 0x8821 /*8821ae*/
|
||||
#define RTL_PCI_8812AE_DID 0x8812 /*8812ae*/
|
||||
#define RTL_PCI_8822BE_DID 0xB822 /*8822be*/
|
||||
|
||||
/*8192 support 16 pages of IO registers*/
|
||||
#define RTL_MEM_MAPPED_IO_RANGE_8190PCI 0x1000
|
||||
#define RTL_MEM_MAPPED_IO_RANGE_8192PCIE 0x4000
|
||||
#define RTL_MEM_MAPPED_IO_RANGE_8192SE 0x4000
|
||||
#define RTL_MEM_MAPPED_IO_RANGE_8192CE 0x4000
|
||||
#define RTL_MEM_MAPPED_IO_RANGE_8192DE 0x4000
|
||||
|
||||
#define RTL_PCI_REVISION_ID_8190PCI 0x00
|
||||
#define RTL_PCI_REVISION_ID_8192PCIE 0x01
|
||||
#define RTL_PCI_REVISION_ID_8192SE 0x10
|
||||
#define RTL_PCI_REVISION_ID_8192CE 0x1
|
||||
#define RTL_PCI_REVISION_ID_8192DE 0x0
|
||||
|
||||
#define RTL_DEFAULT_HARDWARE_TYPE HARDWARE_TYPE_RTL8192CE
|
||||
|
||||
enum pci_bridge_vendor {
|
||||
PCI_BRIDGE_VENDOR_INTEL = 0x0, /*0b'0000,0001 */
|
||||
PCI_BRIDGE_VENDOR_ATI, /*0b'0000,0010*/
|
||||
PCI_BRIDGE_VENDOR_AMD, /*0b'0000,0100*/
|
||||
PCI_BRIDGE_VENDOR_SIS, /*0b'0000,1000*/
|
||||
PCI_BRIDGE_VENDOR_UNKNOWN, /*0b'0100,0000*/
|
||||
PCI_BRIDGE_VENDOR_MAX,
|
||||
};
|
||||
|
||||
struct rtl_pci_capabilities_header {
|
||||
u8 capability_id;
|
||||
u8 next;
|
||||
};
|
||||
|
||||
/* In new TRX flow, Buffer_desc is new concept
|
||||
* But TX wifi info == TX descriptor in old flow
|
||||
* RX wifi info == RX descriptor in old flow
|
||||
*/
|
||||
struct rtl_tx_buffer_desc {
|
||||
u32 dword[4 * (1 << (BUFDESC_SEG_NUM + 1))];
|
||||
} __packed;
|
||||
|
||||
struct rtl_tx_desc {
|
||||
u32 dword[16];
|
||||
} __packed;
|
||||
|
||||
struct rtl_rx_buffer_desc { /*rx buffer desc*/
|
||||
u32 dword[4];
|
||||
} __packed;
|
||||
|
||||
struct rtl_rx_desc { /*old: rx desc new: rx wifi info*/
|
||||
u32 dword[8];
|
||||
} __packed;
|
||||
|
||||
struct rtl_tx_cmd_desc {
|
||||
u32 dword[16];
|
||||
} __packed;
|
||||
|
||||
struct rtl8192_tx_ring {
|
||||
struct rtl_tx_desc *desc;
|
||||
dma_addr_t dma;
|
||||
unsigned int idx;
|
||||
unsigned int entries;
|
||||
struct sk_buff_head queue;
|
||||
/*add for new trx flow*/
|
||||
struct rtl_tx_buffer_desc *buffer_desc; /*tx buffer descriptor*/
|
||||
dma_addr_t buffer_desc_dma; /*tx bufferd desc dma memory*/
|
||||
u16 cur_tx_wp; /* current_tx_write_point */
|
||||
u16 cur_tx_rp; /* current_tx_read_point */
|
||||
};
|
||||
|
||||
struct rtl8192_rx_ring {
|
||||
struct rtl_rx_desc *desc;
|
||||
dma_addr_t dma;
|
||||
unsigned int idx;
|
||||
struct sk_buff *rx_buf[RTL_PCI_MAX_RX_COUNT];
|
||||
/*add for new trx flow*/
|
||||
struct rtl_rx_buffer_desc *buffer_desc; /*rx buffer descriptor*/
|
||||
u16 next_rx_rp; /* next_rx_read_point */
|
||||
};
|
||||
|
||||
struct rtl_pci {
|
||||
struct pci_dev *pdev;
|
||||
bool irq_enabled;
|
||||
|
||||
bool driver_is_goingto_unload;
|
||||
bool up_first_time;
|
||||
bool first_init;
|
||||
bool being_init_adapter;
|
||||
bool init_ready;
|
||||
|
||||
/*Tx */
|
||||
struct rtl8192_tx_ring tx_ring[RTL_PCI_MAX_TX_QUEUE_COUNT];
|
||||
int txringcount[RTL_PCI_MAX_TX_QUEUE_COUNT];
|
||||
u32 transmit_config;
|
||||
|
||||
/*Rx */
|
||||
struct rtl8192_rx_ring rx_ring[RTL_PCI_MAX_RX_QUEUE];
|
||||
int rxringcount;
|
||||
u16 rxbuffersize;
|
||||
u32 receive_config;
|
||||
|
||||
/*irq */
|
||||
u8 irq_alloc;
|
||||
u32 irq_mask[4]; /* 0-1: normal, 2: unused, 3: h2c */
|
||||
u32 sys_irq_mask;
|
||||
|
||||
/*Bcn control register setting */
|
||||
u32 reg_bcn_ctrl_val;
|
||||
|
||||
/*ASPM*/ u8 const_pci_aspm;
|
||||
u8 const_amdpci_aspm;
|
||||
u8 const_hwsw_rfoff_d3;
|
||||
u8 const_support_pciaspm;
|
||||
/*pci-e bridge */
|
||||
u8 const_hostpci_aspm_setting;
|
||||
/*pci-e device */
|
||||
u8 const_devicepci_aspm_setting;
|
||||
/* If it supports ASPM, Offset[560h] = 0x40,
|
||||
* otherwise Offset[560h] = 0x00.
|
||||
*/
|
||||
bool support_aspm;
|
||||
bool support_backdoor;
|
||||
|
||||
/*QOS & EDCA */
|
||||
enum acm_method acm_method;
|
||||
|
||||
u16 shortretry_limit;
|
||||
u16 longretry_limit;
|
||||
|
||||
/* MSI support */
|
||||
bool msi_support;
|
||||
bool using_msi;
|
||||
/* interrupt clear before set */
|
||||
bool int_clear;
|
||||
};
|
||||
|
||||
struct mp_adapter {
|
||||
u8 linkctrl_reg;
|
||||
|
||||
u8 busnumber;
|
||||
u8 devnumber;
|
||||
u8 funcnumber;
|
||||
|
||||
u8 pcibridge_busnum;
|
||||
u8 pcibridge_devnum;
|
||||
u8 pcibridge_funcnum;
|
||||
|
||||
u8 pcibridge_vendor;
|
||||
u16 pcibridge_vendorid;
|
||||
u16 pcibridge_deviceid;
|
||||
|
||||
u8 num4bytes;
|
||||
|
||||
u8 pcibridge_pciehdr_offset;
|
||||
u8 pcibridge_linkctrlreg;
|
||||
|
||||
bool amd_l1_patch;
|
||||
};
|
||||
|
||||
struct rtl_pci_priv {
|
||||
struct bt_coexist_info bt_coexist;
|
||||
struct rtl_led_ctl ledctl;
|
||||
struct rtl_pci dev;
|
||||
struct mp_adapter ndis_adapter;
|
||||
};
|
||||
|
||||
#define rtl_pcipriv(hw) (((struct rtl_pci_priv *)(rtl_priv(hw))->priv))
|
||||
#define rtl_pcidev(pcipriv) (&((pcipriv)->dev))
|
||||
|
||||
int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw);
|
||||
|
||||
extern const struct rtl_intf_ops rtl_pci_ops;
|
||||
|
||||
int rtl_pci_probe(struct pci_dev *pdev,
|
||||
const struct pci_device_id *id);
|
||||
void rtl_pci_disconnect(struct pci_dev *pdev);
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
int rtl_pci_suspend(struct device *dev);
|
||||
int rtl_pci_resume(struct device *dev);
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
|
||||
{
|
||||
return readb((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
|
||||
}
|
||||
|
||||
static inline u16 pci_read16_sync(struct rtl_priv *rtlpriv, u32 addr)
|
||||
{
|
||||
return readw((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
|
||||
}
|
||||
|
||||
static inline u32 pci_read32_sync(struct rtl_priv *rtlpriv, u32 addr)
|
||||
{
|
||||
return readl((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
|
||||
}
|
||||
|
||||
static inline void pci_write8_async(struct rtl_priv *rtlpriv, u32 addr, u8 val)
|
||||
{
|
||||
writeb(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
|
||||
}
|
||||
|
||||
static inline void pci_write16_async(struct rtl_priv *rtlpriv,
|
||||
u32 addr, u16 val)
|
||||
{
|
||||
writew(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
|
||||
}
|
||||
|
||||
static inline void pci_write32_async(struct rtl_priv *rtlpriv,
|
||||
u32 addr, u32 val)
|
||||
{
|
||||
writel(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
|
||||
}
|
||||
|
||||
static inline u16 calc_fifo_space(u16 rp, u16 wp, u16 size)
|
||||
{
|
||||
if (rp <= wp)
|
||||
return size - 1 + rp - wp;
|
||||
return rp - wp - 1;
|
||||
}
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,50 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __REALTEK_RTL_PCI_PS_H__
|
||||
#define __REALTEK_RTL_PCI_PS_H__
|
||||
|
||||
#define MAX_SW_LPS_SLEEP_INTV 5
|
||||
|
||||
bool rtl_ps_enable_nic(struct ieee80211_hw *hw);
|
||||
bool rtl_ps_disable_nic(struct ieee80211_hw *hw);
|
||||
void rtl_ips_nic_off(struct ieee80211_hw *hw);
|
||||
void rtl_ips_nic_on(struct ieee80211_hw *hw);
|
||||
void rtl_ips_nic_off_wq_callback(void *data);
|
||||
void rtl_lps_enter(struct ieee80211_hw *hw);
|
||||
void rtl_lps_leave(struct ieee80211_hw *hw);
|
||||
|
||||
void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode);
|
||||
|
||||
void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len);
|
||||
void rtl_swlps_wq_callback(void *data);
|
||||
void rtl_swlps_rfon_wq_callback(void *data);
|
||||
void rtl_swlps_rf_awake(struct ieee80211_hw *hw);
|
||||
void rtl_swlps_rf_sleep(struct ieee80211_hw *hw);
|
||||
void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
|
||||
void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len);
|
||||
void rtl_lps_change_work_callback(struct work_struct *work);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,94 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL8723E_PWRSEQCMD_H__
|
||||
#define __RTL8723E_PWRSEQCMD_H__
|
||||
|
||||
#include "wifi.h"
|
||||
/*---------------------------------------------
|
||||
* 3 The value of cmd: 4 bits
|
||||
*---------------------------------------------
|
||||
*/
|
||||
#define PWR_CMD_READ 0x00
|
||||
#define PWR_CMD_WRITE 0x01
|
||||
#define PWR_CMD_POLLING 0x02
|
||||
#define PWR_CMD_DELAY 0x03
|
||||
#define PWR_CMD_END 0x04
|
||||
|
||||
/* define the base address of each block */
|
||||
#define PWR_BASEADDR_MAC 0x00
|
||||
#define PWR_BASEADDR_USB 0x01
|
||||
#define PWR_BASEADDR_PCIE 0x02
|
||||
#define PWR_BASEADDR_SDIO 0x03
|
||||
|
||||
#define PWR_INTF_SDIO_MSK BIT(0)
|
||||
#define PWR_INTF_USB_MSK BIT(1)
|
||||
#define PWR_INTF_PCI_MSK BIT(2)
|
||||
#define PWR_INTF_ALL_MSK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
|
||||
|
||||
#define PWR_FAB_TSMC_MSK BIT(0)
|
||||
#define PWR_FAB_UMC_MSK BIT(1)
|
||||
#define PWR_FAB_ALL_MSK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
|
||||
|
||||
#define PWR_CUT_TESTCHIP_MSK BIT(0)
|
||||
#define PWR_CUT_A_MSK BIT(1)
|
||||
#define PWR_CUT_B_MSK BIT(2)
|
||||
#define PWR_CUT_C_MSK BIT(3)
|
||||
#define PWR_CUT_D_MSK BIT(4)
|
||||
#define PWR_CUT_E_MSK BIT(5)
|
||||
#define PWR_CUT_F_MSK BIT(6)
|
||||
#define PWR_CUT_G_MSK BIT(7)
|
||||
#define PWR_CUT_ALL_MSK 0xFF
|
||||
|
||||
enum pwrseq_delay_unit {
|
||||
PWRSEQ_DELAY_US,
|
||||
PWRSEQ_DELAY_MS,
|
||||
};
|
||||
|
||||
struct wlan_pwr_cfg {
|
||||
u16 offset;
|
||||
u8 cut_msk;
|
||||
u8 fab_msk:4;
|
||||
u8 interface_msk:4;
|
||||
u8 base:4;
|
||||
u8 cmd:4;
|
||||
u8 msk;
|
||||
u8 value;
|
||||
};
|
||||
|
||||
#define GET_PWR_CFG_OFFSET(__PWR_CMD) (__PWR_CMD.offset)
|
||||
#define GET_PWR_CFG_CUT_MASK(__PWR_CMD) (__PWR_CMD.cut_msk)
|
||||
#define GET_PWR_CFG_FAB_MASK(__PWR_CMD) (__PWR_CMD.fab_msk)
|
||||
#define GET_PWR_CFG_INTF_MASK(__PWR_CMD) (__PWR_CMD.interface_msk)
|
||||
#define GET_PWR_CFG_BASE(__PWR_CMD) (__PWR_CMD.base)
|
||||
#define GET_PWR_CFG_CMD(__PWR_CMD) (__PWR_CMD.cmd)
|
||||
#define GET_PWR_CFG_MASK(__PWR_CMD) (__PWR_CMD.msk)
|
||||
#define GET_PWR_CFG_VALUE(__PWR_CMD) (__PWR_CMD.value)
|
||||
|
||||
bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
|
||||
u8 fab_version, u8 interface_type,
|
||||
struct wlan_pwr_cfg pwrcfgcmd[]);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,322 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include "wifi.h"
|
||||
#include "base.h"
|
||||
#include "rc.h"
|
||||
|
||||
/*
|
||||
*Finds the highest rate index we can use
|
||||
*if skb is special data like DHCP/EAPOL, we set should
|
||||
*it to lowest rate CCK_1M, otherwise we set rate to
|
||||
*highest rate based on wireless mode used for iwconfig
|
||||
*show Tx rate.
|
||||
*/
|
||||
static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv,
|
||||
struct ieee80211_sta *sta,
|
||||
struct sk_buff *skb, bool not_data)
|
||||
{
|
||||
struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
|
||||
struct rtl_phy *rtlphy = &rtlpriv->phy;
|
||||
struct rtl_sta_info *sta_entry = NULL;
|
||||
u16 wireless_mode = 0;
|
||||
u8 nss; /* NSS -1 */
|
||||
|
||||
if (get_rf_type(rtlphy) >= RF_4T4R)
|
||||
nss = 3;
|
||||
else if (get_rf_type(rtlphy) >= RF_3T3R)
|
||||
nss = 2;
|
||||
else if (get_rf_type(rtlphy) >= RF_2T2R)
|
||||
nss = 1;
|
||||
else
|
||||
nss = 0;
|
||||
|
||||
/*
|
||||
*this rate is no use for true rate, firmware
|
||||
*will control rate at all it just used for
|
||||
*1.show in iwconfig in B/G mode
|
||||
*2.in rtl_get_tcb_desc when we check rate is
|
||||
* 1M we will not use FW rate but user rate.
|
||||
*/
|
||||
|
||||
if (sta) {
|
||||
sta_entry = (struct rtl_sta_info *)sta->drv_priv;
|
||||
wireless_mode = sta_entry->wireless_mode;
|
||||
}
|
||||
|
||||
if (rtl_is_special_data(rtlpriv->mac80211.hw, skb, true, false) ||
|
||||
not_data) {
|
||||
return 0;
|
||||
}
|
||||
if (rtlhal->current_bandtype == BAND_ON_2_4G) {
|
||||
if (wireless_mode == WIRELESS_MODE_B) {
|
||||
return B_MODE_MAX_RIX;
|
||||
} else if (wireless_mode == WIRELESS_MODE_G) {
|
||||
return G_MODE_MAX_RIX;
|
||||
} else if (wireless_mode == WIRELESS_MODE_N_24G) {
|
||||
if (nss == 0)
|
||||
return N_MODE_MCS7_RIX;
|
||||
else
|
||||
return N_MODE_MCS15_RIX;
|
||||
} else if (wireless_mode == WIRELESS_MODE_AC_24G) {
|
||||
if (sta->bandwidth == IEEE80211_STA_RX_BW_20)
|
||||
return AC_MODE_MCS8_RIX | (nss << 4);
|
||||
else
|
||||
return AC_MODE_MCS9_RIX | (nss << 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (wireless_mode == WIRELESS_MODE_A) {
|
||||
return A_MODE_MAX_RIX;
|
||||
} else if (wireless_mode == WIRELESS_MODE_N_5G) {
|
||||
if (nss == 0)
|
||||
return N_MODE_MCS7_RIX;
|
||||
else
|
||||
return N_MODE_MCS15_RIX;
|
||||
} else if (wireless_mode == WIRELESS_MODE_AC_5G) {
|
||||
if (sta->bandwidth == IEEE80211_STA_RX_BW_20)
|
||||
return AC_MODE_MCS8_RIX | (nss << 4);
|
||||
else
|
||||
return AC_MODE_MCS9_RIX | (nss << 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
|
||||
struct ieee80211_sta *sta,
|
||||
struct ieee80211_tx_rate *rate,
|
||||
struct ieee80211_tx_rate_control *txrc,
|
||||
u8 tries, s8 rix, int rtsctsenable,
|
||||
bool not_data)
|
||||
{
|
||||
struct rtl_mac *mac = rtl_mac(rtlpriv);
|
||||
struct rtl_sta_info *sta_entry = NULL;
|
||||
u16 wireless_mode = 0;
|
||||
u8 sgi_20 = 0, sgi_40 = 0, sgi_80 = 0;
|
||||
|
||||
if (sta) {
|
||||
sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
|
||||
sgi_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
|
||||
sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80;
|
||||
sta_entry = (struct rtl_sta_info *)sta->drv_priv;
|
||||
wireless_mode = sta_entry->wireless_mode;
|
||||
}
|
||||
rate->count = tries;
|
||||
rate->idx = rix >= 0x00 ? rix : 0x00;
|
||||
if (((rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE) ||
|
||||
(rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8822BE)) &&
|
||||
wireless_mode == WIRELESS_MODE_AC_5G)
|
||||
rate->idx |= 0x10;/*2NSS for 8812AE, 8822BE*/
|
||||
|
||||
if (!not_data) {
|
||||
if (txrc->short_preamble)
|
||||
rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
|
||||
if (mac->opmode == NL80211_IFTYPE_AP ||
|
||||
mac->opmode == NL80211_IFTYPE_ADHOC) {
|
||||
if (sta && (sta->ht_cap.cap &
|
||||
IEEE80211_HT_CAP_SUP_WIDTH_20_40))
|
||||
rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
|
||||
if (sta && (sta->vht_cap.vht_supported))
|
||||
rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
|
||||
} else {
|
||||
if (mac->bw_80)
|
||||
rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
|
||||
else if (mac->bw_40)
|
||||
rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
|
||||
}
|
||||
|
||||
if (sgi_20 || sgi_40 || sgi_80)
|
||||
rate->flags |= IEEE80211_TX_RC_SHORT_GI;
|
||||
if (sta && sta->ht_cap.ht_supported &&
|
||||
((wireless_mode == WIRELESS_MODE_N_5G) ||
|
||||
(wireless_mode == WIRELESS_MODE_N_24G)))
|
||||
rate->flags |= IEEE80211_TX_RC_MCS;
|
||||
if (sta && sta->vht_cap.vht_supported &&
|
||||
(wireless_mode == WIRELESS_MODE_AC_5G ||
|
||||
wireless_mode == WIRELESS_MODE_AC_24G ||
|
||||
wireless_mode == WIRELESS_MODE_AC_ONLY))
|
||||
rate->flags |= IEEE80211_TX_RC_VHT_MCS;
|
||||
}
|
||||
}
|
||||
|
||||
static void rtl_get_rate(void *ppriv, struct ieee80211_sta *sta,
|
||||
void *priv_sta,
|
||||
struct ieee80211_tx_rate_control *txrc)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = ppriv;
|
||||
struct sk_buff *skb = txrc->skb;
|
||||
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
|
||||
struct ieee80211_tx_rate *rates = tx_info->control.rates;
|
||||
__le16 fc = rtl_get_fc(skb);
|
||||
u8 try_per_rate, i, rix;
|
||||
bool not_data = !ieee80211_is_data(fc);
|
||||
|
||||
if (rate_control_send_low(sta, priv_sta, txrc))
|
||||
return;
|
||||
|
||||
rix = _rtl_rc_get_highest_rix(rtlpriv, sta, skb, not_data);
|
||||
try_per_rate = 1;
|
||||
_rtl_rc_rate_set_series(rtlpriv, sta, &rates[0], txrc,
|
||||
try_per_rate, rix, 1, not_data);
|
||||
|
||||
if (!not_data) {
|
||||
for (i = 1; i < 4; i++)
|
||||
_rtl_rc_rate_set_series(rtlpriv, sta, &rates[i],
|
||||
txrc, i, (rix - i), 1,
|
||||
not_data);
|
||||
}
|
||||
}
|
||||
|
||||
static bool _rtl_tx_aggr_check(struct rtl_priv *rtlpriv,
|
||||
struct rtl_sta_info *sta_entry, u16 tid)
|
||||
{
|
||||
struct rtl_mac *mac = rtl_mac(rtlpriv);
|
||||
|
||||
if (mac->act_scanning)
|
||||
return false;
|
||||
|
||||
if (mac->opmode == NL80211_IFTYPE_STATION &&
|
||||
mac->cnt_after_linked < 3)
|
||||
return false;
|
||||
|
||||
if (sta_entry->tids[tid].agg.agg_state == RTL_AGG_STOP)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*mac80211 Rate Control callbacks*/
|
||||
static void rtl_tx_status(void *ppriv,
|
||||
struct ieee80211_supported_band *sband,
|
||||
struct ieee80211_sta *sta, void *priv_sta,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = ppriv;
|
||||
struct rtl_mac *mac = rtl_mac(rtlpriv);
|
||||
struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
|
||||
__le16 fc = rtl_get_fc(skb);
|
||||
struct rtl_sta_info *sta_entry;
|
||||
|
||||
if (!priv_sta || !ieee80211_is_data(fc))
|
||||
return;
|
||||
|
||||
if (rtl_is_special_data(mac->hw, skb, true, true))
|
||||
return;
|
||||
|
||||
if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
|
||||
is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
|
||||
return;
|
||||
|
||||
if (sta) {
|
||||
/* Check if aggregation has to be enabled for this tid */
|
||||
sta_entry = (struct rtl_sta_info *)sta->drv_priv;
|
||||
if ((sta->ht_cap.ht_supported) &&
|
||||
!(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
|
||||
if (ieee80211_is_data_qos(fc)) {
|
||||
u8 tid = rtl_get_tid(skb);
|
||||
|
||||
if (_rtl_tx_aggr_check(rtlpriv, sta_entry,
|
||||
tid)) {
|
||||
sta_entry->tids[tid].agg.agg_state =
|
||||
RTL_AGG_PROGRESS;
|
||||
ieee80211_start_tx_ba_session(sta, tid,
|
||||
5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rtl_rate_init(void *ppriv,
|
||||
struct ieee80211_supported_band *sband,
|
||||
struct cfg80211_chan_def *chandef,
|
||||
struct ieee80211_sta *sta, void *priv_sta)
|
||||
{
|
||||
}
|
||||
|
||||
static void rtl_rate_update(void *ppriv,
|
||||
struct ieee80211_supported_band *sband,
|
||||
struct cfg80211_chan_def *chandef,
|
||||
struct ieee80211_sta *sta, void *priv_sta,
|
||||
u32 changed)
|
||||
{
|
||||
}
|
||||
|
||||
static void *rtl_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
return rtlpriv;
|
||||
}
|
||||
|
||||
static void rtl_rate_free(void *rtlpriv)
|
||||
{
|
||||
}
|
||||
|
||||
static void *rtl_rate_alloc_sta(void *ppriv,
|
||||
struct ieee80211_sta *sta, gfp_t gfp)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = ppriv;
|
||||
struct rtl_rate_priv *rate_priv;
|
||||
|
||||
rate_priv = kzalloc(sizeof(*rate_priv), gfp);
|
||||
if (!rate_priv) {
|
||||
pr_err("Unable to allocate private rc structure\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rtlpriv->rate_priv = rate_priv;
|
||||
|
||||
return rate_priv;
|
||||
}
|
||||
|
||||
static void rtl_rate_free_sta(void *rtlpriv,
|
||||
struct ieee80211_sta *sta, void *priv_sta)
|
||||
{
|
||||
struct rtl_rate_priv *rate_priv = priv_sta;
|
||||
|
||||
kfree(rate_priv);
|
||||
}
|
||||
|
||||
static const struct rate_control_ops rtl_rate_ops = {
|
||||
.name = "rtl_rc",
|
||||
.alloc = rtl_rate_alloc,
|
||||
.free = rtl_rate_free,
|
||||
.alloc_sta = rtl_rate_alloc_sta,
|
||||
.free_sta = rtl_rate_free_sta,
|
||||
.rate_init = rtl_rate_init,
|
||||
.rate_update = rtl_rate_update,
|
||||
.tx_status = rtl_tx_status,
|
||||
.get_rate = rtl_get_rate,
|
||||
};
|
||||
|
||||
int rtl_rate_control_register(void)
|
||||
{
|
||||
return ieee80211_rate_control_register(&rtl_rate_ops);
|
||||
}
|
||||
|
||||
void rtl_rate_control_unregister(void)
|
||||
{
|
||||
ieee80211_rate_control_unregister(&rtl_rate_ops);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_RC_H__
|
||||
#define __RTL_RC_H__
|
||||
|
||||
#define B_MODE_MAX_RIX 3
|
||||
#define G_MODE_MAX_RIX 11
|
||||
#define A_MODE_MAX_RIX 7
|
||||
|
||||
/* in mac80211 mcs0-mcs15 is idx0-idx15*/
|
||||
#define N_MODE_MCS7_RIX 7
|
||||
#define N_MODE_MCS15_RIX 15
|
||||
|
||||
/* in mac80211 vht mcs0-9 is in [3:0], nss is in [:4] */
|
||||
#define AC_MODE_MCS7_RIX 7
|
||||
#define AC_MODE_MCS8_RIX 8
|
||||
#define AC_MODE_MCS9_RIX 9
|
||||
|
||||
struct rtl_rate_priv {
|
||||
u8 ht_cap;
|
||||
};
|
||||
|
||||
int rtl_rate_control_register(void);
|
||||
void rtl_rate_control_unregister(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,469 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include "wifi.h"
|
||||
#include "regd.h"
|
||||
|
||||
static struct country_code_to_enum_rd allcountries[] = {
|
||||
{COUNTRY_CODE_FCC, "US"},
|
||||
{COUNTRY_CODE_IC, "US"},
|
||||
{COUNTRY_CODE_ETSI, "EC"},
|
||||
{COUNTRY_CODE_SPAIN, "EC"},
|
||||
{COUNTRY_CODE_FRANCE, "EC"},
|
||||
{COUNTRY_CODE_MKK, "JP"},
|
||||
{COUNTRY_CODE_MKK1, "JP"},
|
||||
{COUNTRY_CODE_ISRAEL, "EC"},
|
||||
{COUNTRY_CODE_TELEC, "JP"},
|
||||
{COUNTRY_CODE_MIC, "JP"},
|
||||
{COUNTRY_CODE_GLOBAL_DOMAIN, "JP"},
|
||||
{COUNTRY_CODE_WORLD_WIDE_13, "EC"},
|
||||
{COUNTRY_CODE_TELEC_NETGEAR, "EC"},
|
||||
{COUNTRY_CODE_WORLD_WIDE_13_5G_ALL, "US"},
|
||||
};
|
||||
|
||||
/*Only these channels all allow active
|
||||
*scan on all world regulatory domains
|
||||
*/
|
||||
#define RTL819x_2GHZ_CH01_11 \
|
||||
REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0)
|
||||
|
||||
/*We enable active scan on these a case
|
||||
*by case basis by regulatory domain
|
||||
*/
|
||||
#define RTL819x_2GHZ_CH12_13 \
|
||||
REG_RULE(2467 - 10, 2472 + 10, 40, 0, 20,\
|
||||
NL80211_RRF_PASSIVE_SCAN)
|
||||
|
||||
#define RTL819x_2GHZ_CH14 \
|
||||
REG_RULE(2484 - 10, 2484 + 10, 40, 0, 20, \
|
||||
NL80211_RRF_PASSIVE_SCAN | \
|
||||
NL80211_RRF_NO_OFDM)
|
||||
|
||||
/* 5G chan 36 - chan 64*/
|
||||
#define RTL819x_5GHZ_5150_5350 \
|
||||
REG_RULE(5150 - 10, 5350 + 10, 80, 0, 30, 0)
|
||||
/* 5G chan 100 - chan 165*/
|
||||
#define RTL819x_5GHZ_5470_5850 \
|
||||
REG_RULE(5470 - 10, 5850 + 10, 80, 0, 30, 0)
|
||||
/* 5G chan 149 - chan 165*/
|
||||
#define RTL819x_5GHZ_5725_5850 \
|
||||
REG_RULE(5725 - 10, 5850 + 10, 80, 0, 30, 0)
|
||||
|
||||
#define RTL819x_5GHZ_ALL \
|
||||
(RTL819x_5GHZ_5150_5350, RTL819x_5GHZ_5470_5850)
|
||||
|
||||
static const struct ieee80211_regdomain rtl_regdom_11 = {
|
||||
.n_reg_rules = 1,
|
||||
.alpha2 = "99",
|
||||
.reg_rules = {
|
||||
RTL819x_2GHZ_CH01_11,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct ieee80211_regdomain rtl_regdom_12_13 = {
|
||||
.n_reg_rules = 2,
|
||||
.alpha2 = "99",
|
||||
.reg_rules = {
|
||||
RTL819x_2GHZ_CH01_11,
|
||||
RTL819x_2GHZ_CH12_13,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct ieee80211_regdomain rtl_regdom_no_midband = {
|
||||
.n_reg_rules = 3,
|
||||
.alpha2 = "99",
|
||||
.reg_rules = {
|
||||
RTL819x_2GHZ_CH01_11,
|
||||
RTL819x_5GHZ_5150_5350,
|
||||
RTL819x_5GHZ_5725_5850,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct ieee80211_regdomain rtl_regdom_60_64 = {
|
||||
.n_reg_rules = 3,
|
||||
.alpha2 = "99",
|
||||
.reg_rules = {
|
||||
RTL819x_2GHZ_CH01_11,
|
||||
RTL819x_2GHZ_CH12_13,
|
||||
RTL819x_5GHZ_5725_5850,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct ieee80211_regdomain rtl_regdom_14_60_64 = {
|
||||
.n_reg_rules = 4,
|
||||
.alpha2 = "99",
|
||||
.reg_rules = {
|
||||
RTL819x_2GHZ_CH01_11,
|
||||
RTL819x_2GHZ_CH12_13,
|
||||
RTL819x_2GHZ_CH14,
|
||||
RTL819x_5GHZ_5725_5850,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct ieee80211_regdomain rtl_regdom_12_13_5g_all = {
|
||||
.n_reg_rules = 4,
|
||||
.alpha2 = "99",
|
||||
.reg_rules = {
|
||||
RTL819x_2GHZ_CH01_11,
|
||||
RTL819x_2GHZ_CH12_13,
|
||||
RTL819x_5GHZ_5150_5350,
|
||||
RTL819x_5GHZ_5470_5850,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct ieee80211_regdomain rtl_regdom_14 = {
|
||||
.n_reg_rules = 3,
|
||||
.alpha2 = "99",
|
||||
.reg_rules = {
|
||||
RTL819x_2GHZ_CH01_11,
|
||||
RTL819x_2GHZ_CH12_13,
|
||||
RTL819x_2GHZ_CH14,
|
||||
}
|
||||
};
|
||||
|
||||
static bool _rtl_is_radar_freq(u16 center_freq)
|
||||
{
|
||||
return center_freq >= 5260 && center_freq <= 5700;
|
||||
}
|
||||
|
||||
static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
|
||||
enum nl80211_reg_initiator initiator)
|
||||
{
|
||||
enum nl80211_band band;
|
||||
struct ieee80211_supported_band *sband;
|
||||
const struct ieee80211_reg_rule *reg_rule;
|
||||
struct ieee80211_channel *ch;
|
||||
unsigned int i;
|
||||
|
||||
for (band = 0; band < NUM_NL80211_BANDS; band++) {
|
||||
if (!wiphy->bands[band])
|
||||
continue;
|
||||
|
||||
sband = wiphy->bands[band];
|
||||
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
ch = &sband->channels[i];
|
||||
if (_rtl_is_radar_freq(ch->center_freq) ||
|
||||
(ch->flags & IEEE80211_CHAN_RADAR))
|
||||
continue;
|
||||
if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
|
||||
reg_rule = freq_reg_info(wiphy,
|
||||
ch->center_freq);
|
||||
if (IS_ERR(reg_rule))
|
||||
continue;
|
||||
/*
|
||||
*If 11d had a rule for this channel ensure
|
||||
*we enable adhoc/beaconing if it allows us to
|
||||
*use it. Note that we would have disabled it
|
||||
*by applying our static world regdomain by
|
||||
*default during init, prior to calling our
|
||||
*regulatory_hint().
|
||||
*/
|
||||
|
||||
if (!(reg_rule->flags & NL80211_RRF_NO_IBSS))
|
||||
ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
|
||||
if (!(reg_rule->flags &
|
||||
NL80211_RRF_PASSIVE_SCAN))
|
||||
ch->flags &=
|
||||
~IEEE80211_CHAN_PASSIVE_SCAN;
|
||||
} else {
|
||||
if (ch->beacon_found)
|
||||
ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
|
||||
IEEE80211_CHAN_PASSIVE_SCAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Allows active scan scan on Ch 12 and 13 */
|
||||
static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
|
||||
enum nl80211_reg_initiator
|
||||
initiator)
|
||||
{
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct ieee80211_channel *ch;
|
||||
const struct ieee80211_reg_rule *reg_rule;
|
||||
|
||||
if (!wiphy->bands[NL80211_BAND_2GHZ])
|
||||
return;
|
||||
sband = wiphy->bands[NL80211_BAND_2GHZ];
|
||||
|
||||
/*
|
||||
*If no country IE has been received always enable active scan
|
||||
*on these channels. This is only done for specific regulatory SKUs
|
||||
*/
|
||||
if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
|
||||
ch = &sband->channels[11]; /* CH 12 */
|
||||
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
|
||||
ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
|
||||
ch = &sband->channels[12]; /* CH 13 */
|
||||
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
|
||||
ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
|
||||
return;
|
||||
}
|
||||
|
||||
/*If a country IE has been received check its rule for this
|
||||
*channel first before enabling active scan. The passive scan
|
||||
*would have been enforced by the initial processing of our
|
||||
*custom regulatory domain.
|
||||
*/
|
||||
|
||||
ch = &sband->channels[11]; /* CH 12 */
|
||||
reg_rule = freq_reg_info(wiphy, ch->center_freq);
|
||||
if (!IS_ERR(reg_rule)) {
|
||||
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
|
||||
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
|
||||
ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
|
||||
}
|
||||
|
||||
ch = &sband->channels[12]; /* CH 13 */
|
||||
reg_rule = freq_reg_info(wiphy, ch->center_freq);
|
||||
if (!IS_ERR(reg_rule)) {
|
||||
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
|
||||
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
|
||||
ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*Always apply Radar/DFS rules on
|
||||
*freq range 5260 MHz - 5700 MHz
|
||||
*/
|
||||
static void _rtl_reg_apply_radar_flags(struct wiphy *wiphy)
|
||||
{
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct ieee80211_channel *ch;
|
||||
unsigned int i;
|
||||
|
||||
if (!wiphy->bands[NL80211_BAND_5GHZ])
|
||||
return;
|
||||
|
||||
sband = wiphy->bands[NL80211_BAND_5GHZ];
|
||||
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
ch = &sband->channels[i];
|
||||
if (!_rtl_is_radar_freq(ch->center_freq))
|
||||
continue;
|
||||
|
||||
/*
|
||||
*We always enable radar detection/DFS on this
|
||||
*frequency range. Additionally we also apply on
|
||||
*this frequency range:
|
||||
*- If STA mode does not yet have DFS supports disable
|
||||
* active scanning
|
||||
*- If adhoc mode does not support DFS yet then disable
|
||||
* adhoc in the frequency.
|
||||
*- If AP mode does not yet support radar detection/DFS
|
||||
*do not allow AP mode
|
||||
*/
|
||||
if (!(ch->flags & IEEE80211_CHAN_DISABLED))
|
||||
ch->flags |= IEEE80211_CHAN_RADAR |
|
||||
IEEE80211_CHAN_NO_IBSS |
|
||||
IEEE80211_CHAN_PASSIVE_SCAN;
|
||||
}
|
||||
}
|
||||
|
||||
static void _rtl_reg_apply_world_flags(struct wiphy *wiphy,
|
||||
enum nl80211_reg_initiator initiator,
|
||||
struct rtl_regulatory *reg)
|
||||
{
|
||||
_rtl_reg_apply_beaconing_flags(wiphy, initiator);
|
||||
_rtl_reg_apply_active_scan_flags(wiphy, initiator);
|
||||
}
|
||||
|
||||
static void _rtl_dump_channel_map(struct wiphy *wiphy)
|
||||
{
|
||||
enum nl80211_band band;
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct ieee80211_channel *ch;
|
||||
unsigned int i;
|
||||
|
||||
for (band = 0; band < NUM_NL80211_BANDS; band++) {
|
||||
if (!wiphy->bands[band])
|
||||
continue;
|
||||
sband = wiphy->bands[band];
|
||||
for (i = 0; i < sband->n_channels; i++)
|
||||
ch = &sband->channels[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int _rtl_reg_notifier_apply(struct wiphy *wiphy,
|
||||
struct regulatory_request *request,
|
||||
struct rtl_regulatory *reg)
|
||||
{
|
||||
/* We always apply this */
|
||||
_rtl_reg_apply_radar_flags(wiphy);
|
||||
|
||||
switch (request->initiator) {
|
||||
case NL80211_REGDOM_SET_BY_DRIVER:
|
||||
case NL80211_REGDOM_SET_BY_CORE:
|
||||
case NL80211_REGDOM_SET_BY_USER:
|
||||
break;
|
||||
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
|
||||
_rtl_reg_apply_world_flags(wiphy, request->initiator, reg);
|
||||
break;
|
||||
}
|
||||
|
||||
_rtl_dump_channel_map(wiphy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct ieee80211_regdomain *_rtl_regdomain_select(
|
||||
struct rtl_regulatory *reg)
|
||||
{
|
||||
switch (reg->country_code) {
|
||||
case COUNTRY_CODE_FCC:
|
||||
return &rtl_regdom_no_midband;
|
||||
case COUNTRY_CODE_IC:
|
||||
return &rtl_regdom_11;
|
||||
case COUNTRY_CODE_TELEC_NETGEAR:
|
||||
return &rtl_regdom_60_64;
|
||||
case COUNTRY_CODE_ETSI:
|
||||
case COUNTRY_CODE_SPAIN:
|
||||
case COUNTRY_CODE_FRANCE:
|
||||
case COUNTRY_CODE_ISRAEL:
|
||||
return &rtl_regdom_12_13;
|
||||
case COUNTRY_CODE_MKK:
|
||||
case COUNTRY_CODE_MKK1:
|
||||
case COUNTRY_CODE_TELEC:
|
||||
case COUNTRY_CODE_MIC:
|
||||
return &rtl_regdom_14_60_64;
|
||||
case COUNTRY_CODE_GLOBAL_DOMAIN:
|
||||
return &rtl_regdom_14;
|
||||
case COUNTRY_CODE_WORLD_WIDE_13:
|
||||
case COUNTRY_CODE_WORLD_WIDE_13_5G_ALL:
|
||||
return &rtl_regdom_12_13_5g_all;
|
||||
default:
|
||||
return &rtl_regdom_no_midband;
|
||||
}
|
||||
}
|
||||
|
||||
static int _rtl_regd_init_wiphy(struct rtl_regulatory *reg,
|
||||
struct wiphy *wiphy,
|
||||
void (*reg_notifier)(struct wiphy *wiphy,
|
||||
struct regulatory_request *
|
||||
request))
|
||||
{
|
||||
const struct ieee80211_regdomain *regd;
|
||||
|
||||
wiphy->reg_notifier = reg_notifier;
|
||||
|
||||
wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
|
||||
wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG;
|
||||
wiphy->regulatory_flags &= ~REGULATORY_DISABLE_BEACON_HINTS;
|
||||
regd = _rtl_regdomain_select(reg);
|
||||
wiphy_apply_custom_regulatory(wiphy, regd);
|
||||
_rtl_reg_apply_radar_flags(wiphy);
|
||||
_rtl_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct country_code_to_enum_rd *_rtl_regd_find_country(u16 countrycode)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(allcountries); i++) {
|
||||
if (allcountries[i].countrycode == countrycode)
|
||||
return &allcountries[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static u8 channel_plan_to_country_code(u8 channelplan)
|
||||
{
|
||||
switch (channelplan) {
|
||||
case 0x20:
|
||||
case 0x21:
|
||||
return COUNTRY_CODE_WORLD_WIDE_13;
|
||||
case 0x22:
|
||||
return COUNTRY_CODE_IC;
|
||||
case 0x25:
|
||||
return COUNTRY_CODE_ETSI;
|
||||
case 0x32:
|
||||
return COUNTRY_CODE_TELEC_NETGEAR;
|
||||
case 0x41:
|
||||
return COUNTRY_CODE_GLOBAL_DOMAIN;
|
||||
case 0x7f:
|
||||
return COUNTRY_CODE_WORLD_WIDE_13_5G_ALL;
|
||||
default:
|
||||
return COUNTRY_CODE_MAX; /*Error*/
|
||||
}
|
||||
}
|
||||
|
||||
int rtl_regd_init(struct ieee80211_hw *hw,
|
||||
void (*reg_notifier)(struct wiphy *wiphy,
|
||||
struct regulatory_request *request))
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
struct wiphy *wiphy = hw->wiphy;
|
||||
struct country_code_to_enum_rd *country = NULL;
|
||||
|
||||
if (!wiphy || !&rtlpriv->regd)
|
||||
return -EINVAL;
|
||||
|
||||
/* init country_code from efuse channel plan */
|
||||
rtlpriv->regd.country_code =
|
||||
channel_plan_to_country_code(rtlpriv->efuse.channel_plan);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_REGD, DBG_DMESG,
|
||||
"rtl: EEPROM regdomain: 0x%0x country code: %d\n",
|
||||
rtlpriv->efuse.channel_plan, rtlpriv->regd.country_code);
|
||||
|
||||
if (rtlpriv->regd.country_code >= COUNTRY_CODE_MAX) {
|
||||
RT_TRACE(rtlpriv, COMP_REGD, DBG_DMESG,
|
||||
"rtl: EEPROM indicates invalid country code, world wide 13 should be used\n");
|
||||
|
||||
rtlpriv->regd.country_code = COUNTRY_CODE_WORLD_WIDE_13;
|
||||
}
|
||||
|
||||
country = _rtl_regd_find_country(rtlpriv->regd.country_code);
|
||||
|
||||
if (country) {
|
||||
rtlpriv->regd.alpha2[0] = country->iso_name[0];
|
||||
rtlpriv->regd.alpha2[1] = country->iso_name[1];
|
||||
} else {
|
||||
rtlpriv->regd.alpha2[0] = '0';
|
||||
rtlpriv->regd.alpha2[1] = '0';
|
||||
}
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE,
|
||||
"rtl: Country alpha2 being used: %c%c\n",
|
||||
rtlpriv->regd.alpha2[0], rtlpriv->regd.alpha2[1]);
|
||||
|
||||
_rtl_regd_init_wiphy(&rtlpriv->regd, wiphy, reg_notifier);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
|
||||
{
|
||||
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
|
||||
RT_TRACE(rtlpriv, COMP_REGD, DBG_LOUD, "\n");
|
||||
|
||||
_rtl_reg_notifier_apply(wiphy, request, &rtlpriv->regd);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_REGD_H__
|
||||
#define __RTL_REGD_H__
|
||||
|
||||
/* for kernel 3.14 , both value are changed to IEEE80211_CHAN_NO_IR*/
|
||||
#define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR
|
||||
#define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR
|
||||
|
||||
struct country_code_to_enum_rd {
|
||||
u16 countrycode;
|
||||
const char *iso_name;
|
||||
};
|
||||
|
||||
enum country_code_type_t {
|
||||
COUNTRY_CODE_FCC = 0,
|
||||
COUNTRY_CODE_IC = 1,
|
||||
COUNTRY_CODE_ETSI = 2,
|
||||
COUNTRY_CODE_SPAIN = 3,
|
||||
COUNTRY_CODE_FRANCE = 4,
|
||||
COUNTRY_CODE_MKK = 5,
|
||||
COUNTRY_CODE_MKK1 = 6,
|
||||
COUNTRY_CODE_ISRAEL = 7,
|
||||
COUNTRY_CODE_TELEC = 8,
|
||||
COUNTRY_CODE_MIC = 9,
|
||||
COUNTRY_CODE_GLOBAL_DOMAIN = 10,
|
||||
COUNTRY_CODE_WORLD_WIDE_13 = 11,
|
||||
COUNTRY_CODE_TELEC_NETGEAR = 12,
|
||||
COUNTRY_CODE_WORLD_WIDE_13_5G_ALL = 13,
|
||||
|
||||
/*add new channel plan above this line */
|
||||
COUNTRY_CODE_MAX
|
||||
};
|
||||
|
||||
int rtl_regd_init(struct ieee80211_hw *hw,
|
||||
void (*reg_notifier)(struct wiphy *wiphy,
|
||||
struct regulatory_request *request));
|
||||
void rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,260 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include "wifi.h"
|
||||
#include "stats.h"
|
||||
#include <linux/export.h>
|
||||
|
||||
u8 rtl_query_rxpwrpercentage(s8 antpower)
|
||||
{
|
||||
if ((antpower <= -100) || (antpower >= 20))
|
||||
return 0;
|
||||
else if (antpower >= 0)
|
||||
return 100;
|
||||
else
|
||||
return 100 + antpower;
|
||||
}
|
||||
|
||||
u8 rtl_evm_db_to_percentage(s8 value)
|
||||
{
|
||||
s8 ret_val = clamp(-value, 0, 33) * 3;
|
||||
|
||||
if (ret_val == 99)
|
||||
ret_val = 100;
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
static long rtl_translate_todbm(struct ieee80211_hw *hw,
|
||||
u8 signal_strength_index)
|
||||
{
|
||||
long signal_power;
|
||||
|
||||
signal_power = (long)((signal_strength_index + 1) >> 1);
|
||||
signal_power -= 95;
|
||||
return signal_power;
|
||||
}
|
||||
|
||||
long rtl_signal_scale_mapping(struct ieee80211_hw *hw, long currsig)
|
||||
{
|
||||
long retsig;
|
||||
|
||||
if (currsig >= 61 && currsig <= 100)
|
||||
retsig = 90 + ((currsig - 60) / 4);
|
||||
else if (currsig >= 41 && currsig <= 60)
|
||||
retsig = 78 + ((currsig - 40) / 2);
|
||||
else if (currsig >= 31 && currsig <= 40)
|
||||
retsig = 66 + (currsig - 30);
|
||||
else if (currsig >= 21 && currsig <= 30)
|
||||
retsig = 54 + (currsig - 20);
|
||||
else if (currsig >= 5 && currsig <= 20)
|
||||
retsig = 42 + (((currsig - 5) * 2) / 3);
|
||||
else if (currsig == 4)
|
||||
retsig = 36;
|
||||
else if (currsig == 3)
|
||||
retsig = 27;
|
||||
else if (currsig == 2)
|
||||
retsig = 18;
|
||||
else if (currsig == 1)
|
||||
retsig = 9;
|
||||
else
|
||||
retsig = currsig;
|
||||
|
||||
return retsig;
|
||||
}
|
||||
|
||||
static void rtl_process_ui_rssi(struct ieee80211_hw *hw,
|
||||
struct rtl_stats *pstatus)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
struct rtl_phy *rtlphy = &rtlpriv->phy;
|
||||
u8 rfpath;
|
||||
u32 last_rssi, tmpval;
|
||||
|
||||
if (!pstatus->packet_toself && !pstatus->packet_beacon)
|
||||
return;
|
||||
|
||||
rtlpriv->stats.pwdb_all_cnt += pstatus->rx_pwdb_all;
|
||||
rtlpriv->stats.rssi_calculate_cnt++;
|
||||
|
||||
if (rtlpriv->stats.ui_rssi.total_num++ >= PHY_RSSI_SLID_WIN_MAX) {
|
||||
rtlpriv->stats.ui_rssi.total_num = PHY_RSSI_SLID_WIN_MAX;
|
||||
last_rssi = rtlpriv->stats.ui_rssi.elements[
|
||||
rtlpriv->stats.ui_rssi.index];
|
||||
rtlpriv->stats.ui_rssi.total_val -= last_rssi;
|
||||
}
|
||||
rtlpriv->stats.ui_rssi.total_val += pstatus->signalstrength;
|
||||
rtlpriv->stats.ui_rssi.elements[rtlpriv->stats.ui_rssi.index++] =
|
||||
pstatus->signalstrength;
|
||||
if (rtlpriv->stats.ui_rssi.index >= PHY_RSSI_SLID_WIN_MAX)
|
||||
rtlpriv->stats.ui_rssi.index = 0;
|
||||
tmpval = rtlpriv->stats.ui_rssi.total_val /
|
||||
rtlpriv->stats.ui_rssi.total_num;
|
||||
rtlpriv->stats.signal_strength = rtl_translate_todbm(hw, (u8)tmpval);
|
||||
pstatus->rssi = rtlpriv->stats.signal_strength;
|
||||
|
||||
if (pstatus->is_cck)
|
||||
return;
|
||||
|
||||
for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath;
|
||||
rfpath++) {
|
||||
if (rtlpriv->stats.rx_rssi_percentage[rfpath] == 0) {
|
||||
rtlpriv->stats.rx_rssi_percentage[rfpath] =
|
||||
pstatus->rx_mimo_signalstrength[rfpath];
|
||||
}
|
||||
if (pstatus->rx_mimo_signalstrength[rfpath] >
|
||||
rtlpriv->stats.rx_rssi_percentage[rfpath]) {
|
||||
rtlpriv->stats.rx_rssi_percentage[rfpath] =
|
||||
((rtlpriv->stats.rx_rssi_percentage[rfpath] *
|
||||
(RX_SMOOTH_FACTOR - 1)) +
|
||||
(pstatus->rx_mimo_signalstrength[rfpath])) /
|
||||
(RX_SMOOTH_FACTOR);
|
||||
rtlpriv->stats.rx_rssi_percentage[rfpath] =
|
||||
rtlpriv->stats.rx_rssi_percentage[rfpath] + 1;
|
||||
} else {
|
||||
rtlpriv->stats.rx_rssi_percentage[rfpath] =
|
||||
((rtlpriv->stats.rx_rssi_percentage[rfpath] *
|
||||
(RX_SMOOTH_FACTOR - 1)) +
|
||||
(pstatus->rx_mimo_signalstrength[rfpath])) /
|
||||
(RX_SMOOTH_FACTOR);
|
||||
}
|
||||
rtlpriv->stats.rx_snr_db[rfpath] = pstatus->rx_snr[rfpath];
|
||||
rtlpriv->stats.rx_evm_dbm[rfpath] =
|
||||
pstatus->rx_mimo_evm_dbm[rfpath];
|
||||
rtlpriv->stats.rx_cfo_short[rfpath] =
|
||||
pstatus->cfo_short[rfpath];
|
||||
rtlpriv->stats.rx_cfo_tail[rfpath] = pstatus->cfo_tail[rfpath];
|
||||
}
|
||||
}
|
||||
|
||||
static void rtl_update_rxsignalstatistics(struct ieee80211_hw *hw,
|
||||
struct rtl_stats *pstatus)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
int weighting = 0;
|
||||
|
||||
if (rtlpriv->stats.recv_signal_power == 0)
|
||||
rtlpriv->stats.recv_signal_power = pstatus->recvsignalpower;
|
||||
if (pstatus->recvsignalpower > rtlpriv->stats.recv_signal_power)
|
||||
weighting = 5;
|
||||
else if (pstatus->recvsignalpower < rtlpriv->stats.recv_signal_power)
|
||||
weighting = (-5);
|
||||
rtlpriv->stats.recv_signal_power = (rtlpriv->stats.recv_signal_power *
|
||||
5 + pstatus->recvsignalpower + weighting) / 6;
|
||||
}
|
||||
|
||||
static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
struct rtl_sta_info *drv_priv = NULL;
|
||||
struct ieee80211_sta *sta = NULL;
|
||||
long undec_sm_pwdb;
|
||||
|
||||
rcu_read_lock();
|
||||
if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION)
|
||||
sta = rtl_find_sta(hw, pstatus->psaddr);
|
||||
|
||||
/* adhoc or ap mode */
|
||||
if (sta) {
|
||||
drv_priv = (struct rtl_sta_info *)sta->drv_priv;
|
||||
undec_sm_pwdb = drv_priv->rssi_stat.undec_sm_pwdb;
|
||||
} else {
|
||||
undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
|
||||
}
|
||||
|
||||
if (undec_sm_pwdb < 0)
|
||||
undec_sm_pwdb = pstatus->rx_pwdb_all;
|
||||
if (pstatus->rx_pwdb_all > (u32)undec_sm_pwdb) {
|
||||
undec_sm_pwdb = (((undec_sm_pwdb) *
|
||||
(RX_SMOOTH_FACTOR - 1)) +
|
||||
(pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
|
||||
undec_sm_pwdb = undec_sm_pwdb + 1;
|
||||
} else {
|
||||
undec_sm_pwdb = (((undec_sm_pwdb) *
|
||||
(RX_SMOOTH_FACTOR - 1)) +
|
||||
(pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
|
||||
}
|
||||
|
||||
if (sta)
|
||||
drv_priv->rssi_stat.undec_sm_pwdb = undec_sm_pwdb;
|
||||
else
|
||||
rtlpriv->dm.undec_sm_pwdb = undec_sm_pwdb;
|
||||
rcu_read_unlock();
|
||||
|
||||
rtl_update_rxsignalstatistics(hw, pstatus);
|
||||
}
|
||||
|
||||
static void rtl_process_ui_link_quality(struct ieee80211_hw *hw,
|
||||
struct rtl_stats *pstatus)
|
||||
{
|
||||
struct rtl_priv *rtlpriv = rtl_priv(hw);
|
||||
u32 last_evm, n_stream, tmpval;
|
||||
|
||||
if (pstatus->signalquality == 0)
|
||||
return;
|
||||
|
||||
if (rtlpriv->stats.ui_link_quality.total_num++ >=
|
||||
PHY_LINKQUALITY_SLID_WIN_MAX) {
|
||||
rtlpriv->stats.ui_link_quality.total_num =
|
||||
PHY_LINKQUALITY_SLID_WIN_MAX;
|
||||
last_evm = rtlpriv->stats.ui_link_quality.elements[
|
||||
rtlpriv->stats.ui_link_quality.index];
|
||||
rtlpriv->stats.ui_link_quality.total_val -= last_evm;
|
||||
}
|
||||
rtlpriv->stats.ui_link_quality.total_val += pstatus->signalquality;
|
||||
rtlpriv->stats.ui_link_quality.elements[
|
||||
rtlpriv->stats.ui_link_quality.index++] =
|
||||
pstatus->signalquality;
|
||||
if (rtlpriv->stats.ui_link_quality.index >=
|
||||
PHY_LINKQUALITY_SLID_WIN_MAX)
|
||||
rtlpriv->stats.ui_link_quality.index = 0;
|
||||
tmpval = rtlpriv->stats.ui_link_quality.total_val /
|
||||
rtlpriv->stats.ui_link_quality.total_num;
|
||||
rtlpriv->stats.signal_quality = tmpval;
|
||||
rtlpriv->stats.last_sigstrength_inpercent = tmpval;
|
||||
for (n_stream = 0; n_stream < 2; n_stream++) {
|
||||
if (pstatus->rx_mimo_sig_qual[n_stream] != -1) {
|
||||
if (rtlpriv->stats.rx_evm_percentage[n_stream] == 0) {
|
||||
rtlpriv->stats.rx_evm_percentage[n_stream] =
|
||||
pstatus->rx_mimo_sig_qual[n_stream];
|
||||
}
|
||||
rtlpriv->stats.rx_evm_percentage[n_stream] =
|
||||
((rtlpriv->stats.rx_evm_percentage[n_stream]
|
||||
* (RX_SMOOTH_FACTOR - 1)) +
|
||||
(pstatus->rx_mimo_sig_qual[n_stream] * 1)) /
|
||||
(RX_SMOOTH_FACTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rtl_process_phyinfo(struct ieee80211_hw *hw, u8 *buffer,
|
||||
struct rtl_stats *pstatus)
|
||||
{
|
||||
if (!pstatus->packet_matchbssid)
|
||||
return;
|
||||
|
||||
rtl_process_ui_rssi(hw, pstatus);
|
||||
rtl_process_pwdb(hw, pstatus);
|
||||
rtl_process_ui_link_quality(hw, pstatus);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2009-2012 Realtek Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
* Contact Information:
|
||||
* wlanfae <wlanfae@realtek.com>
|
||||
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
|
||||
* Hsinchu 300, Taiwan.
|
||||
*
|
||||
* Larry Finger <Larry.Finger@lwfinger.net>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __RTL_STATS_H__
|
||||
#define __RTL_STATS_H__
|
||||
|
||||
#define PHY_RSSI_SLID_WIN_MAX 100
|
||||
#define PHY_LINKQUALITY_SLID_WIN_MAX 20
|
||||
#define PHY_BEACON_RSSI_SLID_WIN_MAX 10
|
||||
|
||||
/* Rx smooth factor */
|
||||
#define RX_SMOOTH_FACTOR 20
|
||||
|
||||
u8 rtl_query_rxpwrpercentage(s8 antpower);
|
||||
u8 rtl_evm_db_to_percentage(s8 value);
|
||||
long rtl_signal_scale_mapping(struct ieee80211_hw *hw, long currsig);
|
||||
void rtl_process_phyinfo(struct ieee80211_hw *hw, u8 *buffer,
|
||||
struct rtl_stats *pstatus);
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче