1f1d2b4d3SLarry Finger /****************************************************************************** 2f1d2b4d3SLarry Finger * 3f1d2b4d3SLarry Finger * Copyright(c) 2009-2012 Realtek Corporation. 4f1d2b4d3SLarry Finger * 5f1d2b4d3SLarry Finger * This program is free software; you can redistribute it and/or modify it 6f1d2b4d3SLarry Finger * under the terms of version 2 of the GNU General Public License as 7f1d2b4d3SLarry Finger * published by the Free Software Foundation. 8f1d2b4d3SLarry Finger * 9f1d2b4d3SLarry Finger * This program is distributed in the hope that it will be useful, but WITHOUT 10f1d2b4d3SLarry Finger * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11f1d2b4d3SLarry Finger * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12f1d2b4d3SLarry Finger * more details. 13f1d2b4d3SLarry Finger * 14f1d2b4d3SLarry Finger * The full GNU General Public License is included in this distribution in the 15f1d2b4d3SLarry Finger * file called LICENSE. 16f1d2b4d3SLarry Finger * 17f1d2b4d3SLarry Finger * Contact Information: 18f1d2b4d3SLarry Finger * wlanfae <wlanfae@realtek.com> 19f1d2b4d3SLarry Finger * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20f1d2b4d3SLarry Finger * Hsinchu 300, Taiwan. 21f1d2b4d3SLarry Finger * 22f1d2b4d3SLarry Finger * Larry Finger <Larry.Finger@lwfinger.net> 23f1d2b4d3SLarry Finger * 24f1d2b4d3SLarry Finger *****************************************************************************/ 25f1d2b4d3SLarry Finger 26f1d2b4d3SLarry Finger #ifndef __RTL_BASE_H__ 27f1d2b4d3SLarry Finger #define __RTL_BASE_H__ 28f1d2b4d3SLarry Finger 29f1d2b4d3SLarry Finger enum ap_peer { 30f1d2b4d3SLarry Finger PEER_UNKNOWN = 0, 31f1d2b4d3SLarry Finger PEER_RTL = 1, 32f1d2b4d3SLarry Finger PEER_RTL_92SE = 2, 33f1d2b4d3SLarry Finger PEER_BROAD = 3, 34f1d2b4d3SLarry Finger PEER_RAL = 4, 35f1d2b4d3SLarry Finger PEER_ATH = 5, 36f1d2b4d3SLarry Finger PEER_CISCO = 6, 37f1d2b4d3SLarry Finger PEER_MARV = 7, 38f1d2b4d3SLarry Finger PEER_AIRGO = 9, 39f1d2b4d3SLarry Finger PEER_MAX = 10, 40f1d2b4d3SLarry Finger }; 41f1d2b4d3SLarry Finger 42f1d2b4d3SLarry Finger #define RTL_DUMMY_OFFSET 0 43f1d2b4d3SLarry Finger #define RTL_DUMMY_UNIT 8 44f1d2b4d3SLarry Finger #define RTL_TX_DUMMY_SIZE (RTL_DUMMY_OFFSET * RTL_DUMMY_UNIT) 45f1d2b4d3SLarry Finger #define RTL_TX_DESC_SIZE 32 46f1d2b4d3SLarry Finger #define RTL_TX_HEADER_SIZE (RTL_TX_DESC_SIZE + RTL_TX_DUMMY_SIZE) 47f1d2b4d3SLarry Finger 48f1d2b4d3SLarry Finger #define MAX_BIT_RATE_40MHZ_MCS15 300 /* Mbps */ 49f1d2b4d3SLarry Finger #define MAX_BIT_RATE_40MHZ_MCS7 150 /* Mbps */ 50f1d2b4d3SLarry Finger 51f1d2b4d3SLarry Finger #define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9 867 /* Mbps */ 52f1d2b4d3SLarry Finger #define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS7 650 /* Mbps */ 53f1d2b4d3SLarry Finger #define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS9 780 /* Mbps */ 54f1d2b4d3SLarry Finger #define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS7 585 /* Mbps */ 55f1d2b4d3SLarry Finger 56f1d2b4d3SLarry Finger #define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9 434 /* Mbps */ 57f1d2b4d3SLarry Finger #define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS7 325 /* Mbps */ 58f1d2b4d3SLarry Finger #define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS9 390 /* Mbps */ 59f1d2b4d3SLarry Finger #define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS7 293 /* Mbps */ 60f1d2b4d3SLarry Finger 61f1d2b4d3SLarry Finger #define FRAME_OFFSET_FRAME_CONTROL 0 62f1d2b4d3SLarry Finger #define FRAME_OFFSET_DURATION 2 63f1d2b4d3SLarry Finger #define FRAME_OFFSET_ADDRESS1 4 64f1d2b4d3SLarry Finger #define FRAME_OFFSET_ADDRESS2 10 65f1d2b4d3SLarry Finger #define FRAME_OFFSET_ADDRESS3 16 66f1d2b4d3SLarry Finger #define FRAME_OFFSET_SEQUENCE 22 67f1d2b4d3SLarry Finger #define FRAME_OFFSET_ADDRESS4 24 68*9d546198SSouptick Joarder #define MAX_LISTEN_INTERVAL 10 69*9d546198SSouptick Joarder #define MAX_RATE_TRIES 4 70f1d2b4d3SLarry Finger 71f1d2b4d3SLarry Finger #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val) \ 72f1d2b4d3SLarry Finger WRITEEF2BYTE(_hdr, _val) 73f1d2b4d3SLarry Finger #define SET_80211_HDR_TYPE_AND_SUBTYPE(_hdr, _val) \ 74f1d2b4d3SLarry Finger WRITEEF1BYTE(_hdr, _val) 75f1d2b4d3SLarry Finger #define SET_80211_HDR_PWR_MGNT(_hdr, _val) \ 76f1d2b4d3SLarry Finger SET_BITS_TO_LE_2BYTE(_hdr, 12, 1, _val) 77f1d2b4d3SLarry Finger #define SET_80211_HDR_TO_DS(_hdr, _val) \ 78f1d2b4d3SLarry Finger SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val) 79f1d2b4d3SLarry Finger 80f1d2b4d3SLarry Finger #define SET_80211_PS_POLL_AID(_hdr, _val) \ 81f1d2b4d3SLarry Finger (*(u16 *)((u8 *)(_hdr) + 2) = _val) 82f1d2b4d3SLarry Finger #define SET_80211_PS_POLL_BSSID(_hdr, _val) \ 83f1d2b4d3SLarry Finger ether_addr_copy(((u8 *)(_hdr)) + 4, (u8 *)(_val)) 84f1d2b4d3SLarry Finger #define SET_80211_PS_POLL_TA(_hdr, _val) \ 85f1d2b4d3SLarry Finger ether_addr_copy(((u8 *)(_hdr))+10, (u8 *)(_val)) 86f1d2b4d3SLarry Finger 87f1d2b4d3SLarry Finger #define SET_80211_HDR_DURATION(_hdr, _val) \ 88f1d2b4d3SLarry Finger (*(u16 *)((u8 *)(_hdr) + FRAME_OFFSET_DURATION) = le16_to_cpu(_val)) 89f1d2b4d3SLarry Finger #define SET_80211_HDR_ADDRESS1(_hdr, _val) \ 90f1d2b4d3SLarry Finger CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS1, (u8 *)(_val)) 91f1d2b4d3SLarry Finger #define SET_80211_HDR_ADDRESS2(_hdr, _val) \ 92f1d2b4d3SLarry Finger CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS2, (u8 *)(_val)) 93f1d2b4d3SLarry Finger #define SET_80211_HDR_ADDRESS3(_hdr, _val) \ 94f1d2b4d3SLarry Finger CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS3, (u8 *)(_val)) 95f1d2b4d3SLarry Finger #define SET_80211_HDR_FRAGMENT_SEQUENCE(_hdr, _val) \ 96f1d2b4d3SLarry Finger WRITEEF2BYTE((u8 *)(_hdr)+FRAME_OFFSET_SEQUENCE, _val) 97f1d2b4d3SLarry Finger 98f1d2b4d3SLarry Finger #define SET_BEACON_PROBE_RSP_TIME_STAMP_LOW(__phdr, __val) \ 99f1d2b4d3SLarry Finger WRITEEF4BYTE(((u8 *)(__phdr)) + 24, __val) 100f1d2b4d3SLarry Finger #define SET_BEACON_PROBE_RSP_TIME_STAMP_HIGH(__phdr, __val) \ 101f1d2b4d3SLarry Finger WRITEEF4BYTE(((u8 *)(__phdr)) + 28, __val) 102f1d2b4d3SLarry Finger #define SET_BEACON_PROBE_RSP_BEACON_INTERVAL(__phdr, __val) \ 103f1d2b4d3SLarry Finger WRITEEF2BYTE(((u8 *)(__phdr)) + 32, __val) 104f1d2b4d3SLarry Finger #define GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) \ 105f1d2b4d3SLarry Finger READEF2BYTE(((u8 *)(__phdr)) + 34) 106f1d2b4d3SLarry Finger #define SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \ 107f1d2b4d3SLarry Finger WRITEEF2BYTE(((u8 *)(__phdr)) + 34, __val) 108f1d2b4d3SLarry Finger #define MASK_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \ 109f1d2b4d3SLarry Finger SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, \ 110f1d2b4d3SLarry Finger (GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) & (~(__val)))) 111f1d2b4d3SLarry Finger 1128479580bSPing-Ke Shih #define SET_TX_DESC_SPE_RPT(__pdesc, __val) \ 1138479580bSPing-Ke Shih SET_BITS_TO_LE_4BYTE((__pdesc) + 8, 19, 1, __val) 1148479580bSPing-Ke Shih #define SET_TX_DESC_SW_DEFINE(__pdesc, __val) \ 1158479580bSPing-Ke Shih SET_BITS_TO_LE_4BYTE((__pdesc) + 24, 0, 12, __val) 1168479580bSPing-Ke Shih 117f1d2b4d3SLarry Finger int rtl_init_core(struct ieee80211_hw *hw); 118f1d2b4d3SLarry Finger void rtl_deinit_core(struct ieee80211_hw *hw); 119f1d2b4d3SLarry Finger void rtl_init_rx_config(struct ieee80211_hw *hw); 120f1d2b4d3SLarry Finger void rtl_init_rfkill(struct ieee80211_hw *hw); 121f1d2b4d3SLarry Finger void rtl_deinit_rfkill(struct ieee80211_hw *hw); 122f1d2b4d3SLarry Finger 123f1d2b4d3SLarry Finger void rtl_watch_dog_timer_callback(unsigned long data); 124f1d2b4d3SLarry Finger void rtl_deinit_deferred_work(struct ieee80211_hw *hw); 125f1d2b4d3SLarry Finger 126f1d2b4d3SLarry Finger bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx); 127f1d2b4d3SLarry Finger int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht, 128f1d2b4d3SLarry Finger bool isvht, u8 desc_rate); 129f1d2b4d3SLarry Finger bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb); 130f1d2b4d3SLarry Finger u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx, 131f1d2b4d3SLarry Finger bool is_enc); 132f1d2b4d3SLarry Finger 1338479580bSPing-Ke Shih bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb); 1348479580bSPing-Ke Shih void rtl_get_tx_report(struct rtl_tcb_desc *ptcb_desc, u8 *pdesc, 1358479580bSPing-Ke Shih struct ieee80211_hw *hw); 1368479580bSPing-Ke Shih void rtl_tx_report_handler(struct ieee80211_hw *hw, u8 *tmp_buf, 1378479580bSPing-Ke Shih u8 c2h_cmd_len); 1388479580bSPing-Ke Shih bool rtl_check_tx_report_acked(struct ieee80211_hw *hw); 1398479580bSPing-Ke Shih void rtl_wait_tx_report_acked(struct ieee80211_hw *hw, u32 wait_ms); 1408479580bSPing-Ke Shih 141f1d2b4d3SLarry Finger void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb); 142c76ab8e7SPing-Ke Shih void rtl_collect_scan_list(struct ieee80211_hw *hw, struct sk_buff *skb); 143c76ab8e7SPing-Ke Shih void rtl_scan_list_expire(struct ieee80211_hw *hw); 144f1d2b4d3SLarry Finger int rtl_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 145f1d2b4d3SLarry Finger struct ieee80211_sta *sta, u16 tid, u16 *ssn); 146f1d2b4d3SLarry Finger int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 147f1d2b4d3SLarry Finger struct ieee80211_sta *sta, u16 tid); 148f1d2b4d3SLarry Finger int rtl_tx_agg_oper(struct ieee80211_hw *hw, 149f1d2b4d3SLarry Finger struct ieee80211_sta *sta, u16 tid); 150f1d2b4d3SLarry Finger int rtl_rx_agg_start(struct ieee80211_hw *hw, 151f1d2b4d3SLarry Finger struct ieee80211_sta *sta, u16 tid); 152f1d2b4d3SLarry Finger int rtl_rx_agg_stop(struct ieee80211_hw *hw, 153f1d2b4d3SLarry Finger struct ieee80211_sta *sta, u16 tid); 1542635664eSPing-Ke Shih void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv); 155f1d2b4d3SLarry Finger void rtl_watchdog_wq_callback(void *data); 156f1d2b4d3SLarry Finger void rtl_fwevt_wq_callback(void *data); 157cceb0a59SPing-Ke Shih void rtl_c2hcmd_wq_callback(void *data); 158cceb0a59SPing-Ke Shih void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec); 159cceb0a59SPing-Ke Shih void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val); 160f1d2b4d3SLarry Finger 161f1d2b4d3SLarry Finger void rtl_get_tcb_desc(struct ieee80211_hw *hw, 162f1d2b4d3SLarry Finger struct ieee80211_tx_info *info, 163f1d2b4d3SLarry Finger struct ieee80211_sta *sta, 164f1d2b4d3SLarry Finger struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc); 165f1d2b4d3SLarry Finger 166f1d2b4d3SLarry Finger int rtl_send_smps_action(struct ieee80211_hw *hw, 167f1d2b4d3SLarry Finger struct ieee80211_sta *sta, 168f1d2b4d3SLarry Finger enum ieee80211_smps_mode smps); 169f1d2b4d3SLarry Finger u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie); 170f1d2b4d3SLarry Finger void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len); 171f1d2b4d3SLarry Finger u8 rtl_tid_to_ac(u8 tid); 172f1d2b4d3SLarry Finger void rtl_easy_concurrent_retrytimer_callback(unsigned long data); 173f1d2b4d3SLarry Finger extern struct rtl_global_var rtl_global_var; 174f1d2b4d3SLarry Finger void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation); 175f1d2b4d3SLarry Finger 176f1d2b4d3SLarry Finger #endif 177