base.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /******************************************************************************
  3. *
  4. * Copyright(c) 2009-2012 Realtek Corporation.
  5. *
  6. * Contact Information:
  7. * wlanfae <wlanfae@realtek.com>
  8. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  9. * Hsinchu 300, Taiwan.
  10. *
  11. * Larry Finger <Larry.Finger@lwfinger.net>
  12. *
  13. *****************************************************************************/
  14. #ifndef __RTL_BASE_H__
  15. #define __RTL_BASE_H__
  16. enum ap_peer {
  17. PEER_UNKNOWN = 0,
  18. PEER_RTL = 1,
  19. PEER_RTL_92SE = 2,
  20. PEER_BROAD = 3,
  21. PEER_RAL = 4,
  22. PEER_ATH = 5,
  23. PEER_CISCO = 6,
  24. PEER_MARV = 7,
  25. PEER_AIRGO = 9,
  26. PEER_MAX = 10,
  27. };
  28. #define RTL_DUMMY_OFFSET 0
  29. #define RTL_DUMMY_UNIT 8
  30. #define RTL_TX_DUMMY_SIZE (RTL_DUMMY_OFFSET * RTL_DUMMY_UNIT)
  31. #define RTL_TX_DESC_SIZE 32
  32. #define RTL_TX_HEADER_SIZE (RTL_TX_DESC_SIZE + RTL_TX_DUMMY_SIZE)
  33. #define MAX_BIT_RATE_40MHZ_MCS15 300 /* Mbps */
  34. #define MAX_BIT_RATE_40MHZ_MCS7 150 /* Mbps */
  35. #define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9 867 /* Mbps */
  36. #define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS7 650 /* Mbps */
  37. #define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS9 780 /* Mbps */
  38. #define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS7 585 /* Mbps */
  39. #define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9 434 /* Mbps */
  40. #define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS7 325 /* Mbps */
  41. #define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS9 390 /* Mbps */
  42. #define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS7 293 /* Mbps */
  43. #define FRAME_OFFSET_FRAME_CONTROL 0
  44. #define FRAME_OFFSET_DURATION 2
  45. #define FRAME_OFFSET_ADDRESS1 4
  46. #define FRAME_OFFSET_ADDRESS2 10
  47. #define FRAME_OFFSET_ADDRESS3 16
  48. #define FRAME_OFFSET_SEQUENCE 22
  49. #define FRAME_OFFSET_ADDRESS4 24
  50. #define MAX_LISTEN_INTERVAL 10
  51. #define MAX_RATE_TRIES 4
  52. #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val) \
  53. WRITEEF2BYTE(_hdr, _val)
  54. #define SET_80211_HDR_TYPE_AND_SUBTYPE(_hdr, _val) \
  55. WRITEEF1BYTE(_hdr, _val)
  56. #define SET_80211_HDR_PWR_MGNT(_hdr, _val) \
  57. SET_BITS_TO_LE_2BYTE(_hdr, 12, 1, _val)
  58. #define SET_80211_HDR_TO_DS(_hdr, _val) \
  59. SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val)
  60. #define SET_80211_PS_POLL_AID(_hdr, _val) \
  61. (*(u16 *)((u8 *)(_hdr) + 2) = _val)
  62. #define SET_80211_PS_POLL_BSSID(_hdr, _val) \
  63. ether_addr_copy(((u8 *)(_hdr)) + 4, (u8 *)(_val))
  64. #define SET_80211_PS_POLL_TA(_hdr, _val) \
  65. ether_addr_copy(((u8 *)(_hdr)) + 10, (u8 *)(_val))
  66. #define SET_80211_HDR_DURATION(_hdr, _val) \
  67. (*(u16 *)((u8 *)(_hdr) + FRAME_OFFSET_DURATION) = le16_to_cpu(_val))
  68. #define SET_80211_HDR_ADDRESS1(_hdr, _val) \
  69. CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS1, (u8 *)(_val))
  70. #define SET_80211_HDR_ADDRESS2(_hdr, _val) \
  71. CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS2, (u8 *)(_val))
  72. #define SET_80211_HDR_ADDRESS3(_hdr, _val) \
  73. CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS3, (u8 *)(_val))
  74. #define SET_80211_HDR_FRAGMENT_SEQUENCE(_hdr, _val) \
  75. WRITEEF2BYTE((u8 *)(_hdr) + FRAME_OFFSET_SEQUENCE, _val)
  76. #define SET_BEACON_PROBE_RSP_TIME_STAMP_LOW(__phdr, __val) \
  77. WRITEEF4BYTE(((u8 *)(__phdr)) + 24, __val)
  78. #define SET_BEACON_PROBE_RSP_TIME_STAMP_HIGH(__phdr, __val) \
  79. WRITEEF4BYTE(((u8 *)(__phdr)) + 28, __val)
  80. #define SET_BEACON_PROBE_RSP_BEACON_INTERVAL(__phdr, __val) \
  81. WRITEEF2BYTE(((u8 *)(__phdr)) + 32, __val)
  82. #define GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) \
  83. READEF2BYTE(((u8 *)(__phdr)) + 34)
  84. #define SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
  85. WRITEEF2BYTE(((u8 *)(__phdr)) + 34, __val)
  86. #define MASK_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
  87. SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, \
  88. (GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) & (~(__val))))
  89. #define SET_TX_DESC_SPE_RPT(__pdesc, __val) \
  90. SET_BITS_TO_LE_4BYTE((__pdesc) + 8, 19, 1, __val)
  91. #define SET_TX_DESC_SW_DEFINE(__pdesc, __val) \
  92. SET_BITS_TO_LE_4BYTE((__pdesc) + 24, 0, 12, __val)
  93. int rtl_init_core(struct ieee80211_hw *hw);
  94. void rtl_deinit_core(struct ieee80211_hw *hw);
  95. void rtl_init_rx_config(struct ieee80211_hw *hw);
  96. void rtl_init_rfkill(struct ieee80211_hw *hw);
  97. void rtl_deinit_rfkill(struct ieee80211_hw *hw);
  98. void rtl_watch_dog_timer_callback(struct timer_list *t);
  99. void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
  100. bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
  101. int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht,
  102. bool isvht, u8 desc_rate);
  103. bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
  104. u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
  105. bool is_enc);
  106. bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb);
  107. void rtl_get_tx_report(struct rtl_tcb_desc *ptcb_desc, u8 *pdesc,
  108. struct ieee80211_hw *hw);
  109. void rtl_tx_report_handler(struct ieee80211_hw *hw, u8 *tmp_buf,
  110. u8 c2h_cmd_len);
  111. bool rtl_check_tx_report_acked(struct ieee80211_hw *hw);
  112. void rtl_wait_tx_report_acked(struct ieee80211_hw *hw, u32 wait_ms);
  113. u32 rtl_get_hal_edca_param(struct ieee80211_hw *hw,
  114. struct ieee80211_vif *vif,
  115. enum wireless_mode wirelessmode,
  116. struct ieee80211_tx_queue_params *param);
  117. void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb);
  118. void rtl_collect_scan_list(struct ieee80211_hw *hw, struct sk_buff *skb);
  119. void rtl_scan_list_expire(struct ieee80211_hw *hw);
  120. int rtl_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  121. struct ieee80211_sta *sta, u16 tid, u16 *ssn);
  122. int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  123. struct ieee80211_sta *sta, u16 tid);
  124. int rtl_tx_agg_oper(struct ieee80211_hw *hw,
  125. struct ieee80211_sta *sta, u16 tid);
  126. int rtl_rx_agg_start(struct ieee80211_hw *hw,
  127. struct ieee80211_sta *sta, u16 tid);
  128. int rtl_rx_agg_stop(struct ieee80211_hw *hw,
  129. struct ieee80211_sta *sta, u16 tid);
  130. void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv);
  131. void rtl_watchdog_wq_callback(void *data);
  132. void rtl_fwevt_wq_callback(void *data);
  133. void rtl_c2hcmd_wq_callback(void *data);
  134. void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec);
  135. void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val);
  136. u8 rtl_mrate_idx_to_arfr_id(
  137. struct ieee80211_hw *hw, u8 rate_index,
  138. enum wireless_mode wirelessmode);
  139. void rtl_get_tcb_desc(struct ieee80211_hw *hw,
  140. struct ieee80211_tx_info *info,
  141. struct ieee80211_sta *sta,
  142. struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc);
  143. int rtl_send_smps_action(struct ieee80211_hw *hw,
  144. struct ieee80211_sta *sta,
  145. enum ieee80211_smps_mode smps);
  146. u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie);
  147. void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len);
  148. u8 rtl_tid_to_ac(u8 tid);
  149. void rtl_easy_concurrent_retrytimer_callback(struct timer_list *t);
  150. extern struct rtl_global_var rtl_global_var;
  151. void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation);
  152. bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data,
  153. unsigned int len);
  154. int rtl_core_module_init(void);
  155. void rtl_core_module_exit(void);
  156. #endif