WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / wireless / realtek / rtlwifi / rtl8192cu / trx.h
blob171fe39dfb0c0dd7b8a6725f68495d946960fe12
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
4 #ifndef __RTL92CU_TRX_H__
5 #define __RTL92CU_TRX_H__
7 #define RTL92C_USB_BULK_IN_NUM 1
8 #define RTL92C_NUM_RX_URBS 8
9 #define RTL92C_NUM_TX_URBS 32
11 #define RTL92C_SIZE_MAX_RX_BUFFER 15360 /* 8192 */
12 #define RX_DRV_INFO_SIZE_UNIT 8
14 #define RTL_AGG_ON 1
16 enum usb_rx_agg_mode {
17 USB_RX_AGG_DISABLE,
18 USB_RX_AGG_DMA,
19 USB_RX_AGG_USB,
20 USB_RX_AGG_DMA_USB
23 #define TX_SELE_HQ BIT(0) /* High Queue */
24 #define TX_SELE_LQ BIT(1) /* Low Queue */
25 #define TX_SELE_NQ BIT(2) /* Normal Queue */
27 #define RTL_USB_TX_AGG_NUM_DESC 5
29 #define RTL_USB_RX_AGG_PAGE_NUM 4
30 #define RTL_USB_RX_AGG_PAGE_TIMEOUT 3
32 #define RTL_USB_RX_AGG_BLOCK_NUM 5
33 #define RTL_USB_RX_AGG_BLOCK_TIMEOUT 3
35 /*======================== rx status =========================================*/
37 struct rx_drv_info_92c {
39 * Driver info contain PHY status and other variabel size info
40 * PHY Status content as below
43 /* DWORD 0 */
44 u8 gain_trsw[4];
46 /* DWORD 1 */
47 u8 pwdb_all;
48 u8 cfosho[4];
50 /* DWORD 2 */
51 u8 cfotail[4];
53 /* DWORD 3 */
54 s8 rxevm[2];
55 s8 rxsnr[4];
57 /* DWORD 4 */
58 u8 pdsnr[2];
60 /* DWORD 5 */
61 u8 csi_current[2];
62 u8 csi_target[2];
64 /* DWORD 6 */
65 u8 sigevm;
66 u8 max_ex_pwr;
67 u8 ex_intf_flag:1;
68 u8 sgi_en:1;
69 u8 rxsc:2;
70 u8 reserve:4;
71 } __packed;
73 /* macros to read various fields in RX descriptor */
75 /* DWORD 0 */
76 static inline u32 get_rx_desc_pkt_len(__le32 *__rxdesc)
78 return le32_get_bits(*__rxdesc, GENMASK(13, 0));
81 static inline u32 get_rx_desc_crc32(__le32 *__rxdesc)
83 return le32_get_bits(*__rxdesc, BIT(14));
86 static inline u32 get_rx_desc_icv(__le32 *__rxdesc)
88 return le32_get_bits(*__rxdesc, BIT(15));
91 static inline u32 get_rx_desc_drvinfo_size(__le32 *__rxdesc)
93 return le32_get_bits(*__rxdesc, GENMASK(19, 16));
96 static inline u32 get_rx_desc_shift(__le32 *__rxdesc)
98 return le32_get_bits(*__rxdesc, GENMASK(25, 24));
101 static inline u32 get_rx_desc_phy_status(__le32 *__rxdesc)
103 return le32_get_bits(*__rxdesc, BIT(26));
106 static inline u32 get_rx_desc_swdec(__le32 *__rxdesc)
108 return le32_get_bits(*__rxdesc, BIT(27));
112 /* DWORD 1 */
113 static inline u32 get_rx_desc_paggr(__le32 *__rxdesc)
115 return le32_get_bits(*(__rxdesc + 1), BIT(14));
118 static inline u32 get_rx_desc_faggr(__le32 *__rxdesc)
120 return le32_get_bits(*(__rxdesc + 1), BIT(15));
124 /* DWORD 3 */
125 static inline u32 get_rx_desc_rx_mcs(__le32 *__rxdesc)
127 return le32_get_bits(*(__rxdesc + 3), GENMASK(5, 0));
130 static inline u32 get_rx_desc_rx_ht(__le32 *__rxdesc)
132 return le32_get_bits(*(__rxdesc + 3), BIT(6));
135 static inline u32 get_rx_desc_splcp(__le32 *__rxdesc)
137 return le32_get_bits(*(__rxdesc + 3), BIT(8));
140 static inline u32 get_rx_desc_bw(__le32 *__rxdesc)
142 return le32_get_bits(*(__rxdesc + 3), BIT(9));
146 /* DWORD 5 */
147 static inline u32 get_rx_desc_tsfl(__le32 *__rxdesc)
149 return le32_to_cpu(*((__rxdesc + 5)));
153 /*======================= tx desc ============================================*/
155 /* macros to set various fields in TX descriptor */
157 /* Dword 0 */
158 static inline void set_tx_desc_pkt_size(__le32 *__txdesc, u32 __value)
160 le32p_replace_bits(__txdesc, __value, GENMASK(15, 0));
163 static inline void set_tx_desc_offset(__le32 *__txdesc, u32 __value)
165 le32p_replace_bits(__txdesc, __value, GENMASK(23, 16));
168 static inline void set_tx_desc_bmc(__le32 *__txdesc, u32 __value)
170 le32p_replace_bits(__txdesc, __value, BIT(24));
173 static inline void set_tx_desc_htc(__le32 *__txdesc, u32 __value)
175 le32p_replace_bits(__txdesc, __value, BIT(25));
178 static inline void set_tx_desc_last_seg(__le32 *__txdesc, u32 __value)
180 le32p_replace_bits(__txdesc, __value, BIT(26));
183 static inline void set_tx_desc_first_seg(__le32 *__txdesc, u32 __value)
185 le32p_replace_bits(__txdesc, __value, BIT(27));
188 static inline void set_tx_desc_linip(__le32 *__txdesc, u32 __value)
190 le32p_replace_bits(__txdesc, __value, BIT(28));
193 static inline void set_tx_desc_own(__le32 *__txdesc, u32 __value)
195 le32p_replace_bits(__txdesc, __value, BIT(31));
199 /* Dword 1 */
200 static inline void set_tx_desc_macid(__le32 *__txdesc, u32 __value)
202 le32p_replace_bits((__txdesc + 1), __value, GENMASK(4, 0));
205 static inline void set_tx_desc_agg_enable(__le32 *__txdesc, u32 __value)
207 le32p_replace_bits((__txdesc + 1), __value, BIT(5));
210 static inline void set_tx_desc_agg_break(__le32 *__txdesc, u32 __value)
212 le32p_replace_bits((__txdesc + 1), __value, BIT(6));
215 static inline void set_tx_desc_rdg_enable(__le32 *__txdesc, u32 __value)
217 le32p_replace_bits((__txdesc + 1), __value, BIT(7));
220 static inline void set_tx_desc_queue_sel(__le32 *__txdesc, u32 __value)
222 le32p_replace_bits((__txdesc + 1), __value, GENMASK(12, 8));
225 static inline void set_tx_desc_rate_id(__le32 *__txdesc, u32 __value)
227 le32p_replace_bits((__txdesc + 1), __value, GENMASK(19, 16));
230 static inline void set_tx_desc_nav_use_hdr(__le32 *__txdesc, u32 __value)
232 le32p_replace_bits((__txdesc + 1), __value, BIT(20));
235 static inline void set_tx_desc_sec_type(__le32 *__txdesc, u32 __value)
237 le32p_replace_bits((__txdesc + 1), __value, GENMASK(23, 22));
240 static inline void set_tx_desc_pkt_offset(__le32 *__txdesc, u32 __value)
242 le32p_replace_bits((__txdesc + 1), __value, GENMASK(30, 26));
246 /* Dword 2 */
247 static inline void set_tx_desc_more_frag(__le32 *__txdesc, u32 __value)
249 le32p_replace_bits((__txdesc + 2), __value, BIT(17));
252 static inline void set_tx_desc_ampdu_density(__le32 *__txdesc, u32 __value)
254 le32p_replace_bits((__txdesc + 2), __value, GENMASK(22, 20));
258 /* Dword 3 */
259 static inline void set_tx_desc_seq(__le32 *__txdesc, u32 __value)
261 le32p_replace_bits((__txdesc + 3), __value, GENMASK(27, 16));
264 static inline void set_tx_desc_pkt_id(__le32 *__txdesc, u32 __value)
266 le32p_replace_bits((__txdesc + 3), __value, GENMASK(31, 28));
270 /* Dword 4 */
271 static inline void set_tx_desc_rts_rate(__le32 *__txdesc, u32 __value)
273 le32p_replace_bits((__txdesc + 4), __value, GENMASK(4, 0));
276 static inline void set_tx_desc_qos(__le32 *__txdesc, u32 __value)
278 le32p_replace_bits((__txdesc + 4), __value, BIT(6));
281 static inline void set_tx_desc_hwseq_en(__le32 *__txdesc, u32 __value)
283 le32p_replace_bits((__txdesc + 4), __value, BIT(7));
286 static inline void set_tx_desc_use_rate(__le32 *__txdesc, u32 __value)
288 le32p_replace_bits((__txdesc + 4), __value, BIT(8));
291 static inline void set_tx_desc_disable_fb(__le32 *__txdesc, u32 __value)
293 le32p_replace_bits((__txdesc + 4), __value, BIT(10));
296 static inline void set_tx_desc_cts2self(__le32 *__txdesc, u32 __value)
298 le32p_replace_bits((__txdesc + 4), __value, BIT(11));
301 static inline void set_tx_desc_rts_enable(__le32 *__txdesc, u32 __value)
303 le32p_replace_bits((__txdesc + 4), __value, BIT(12));
306 static inline void set_tx_desc_hw_rts_enable(__le32 *__txdesc, u32 __value)
308 le32p_replace_bits((__txdesc + 4), __value, BIT(13));
311 static inline void set_tx_desc_data_sc(__le32 *__txdesc, u32 __value)
313 le32p_replace_bits((__txdesc + 4), __value, GENMASK(21, 20));
316 static inline void set_tx_desc_data_bw(__le32 *__txdesc, u32 __value)
318 le32p_replace_bits((__txdesc + 4), __value, BIT(25));
321 static inline void set_tx_desc_rts_short(__le32 *__txdesc, u32 __value)
323 le32p_replace_bits((__txdesc + 4), __value, BIT(26));
326 static inline void set_tx_desc_rts_bw(__le32 *__txdesc, u32 __value)
328 le32p_replace_bits((__txdesc + 4), __value, BIT(27));
331 static inline void set_tx_desc_rts_sc(__le32 *__txdesc, u32 __value)
333 le32p_replace_bits((__txdesc + 4), __value, GENMASK(29, 28));
336 static inline void set_tx_desc_rts_stbc(__le32 *__txdesc, u32 __value)
338 le32p_replace_bits((__txdesc + 4), __value, GENMASK(31, 30));
342 /* Dword 5 */
343 static inline void set_tx_desc_tx_rate(__le32 *__pdesc, u32 __val)
345 le32p_replace_bits((__pdesc + 5), __val, GENMASK(5, 0));
348 static inline void set_tx_desc_data_shortgi(__le32 *__pdesc, u32 __val)
350 le32p_replace_bits((__pdesc + 5), __val, BIT(6));
353 static inline void set_tx_desc_data_rate_fb_limit(__le32 *__txdesc, u32 __value)
355 le32p_replace_bits((__txdesc + 5), __value, GENMASK(12, 8));
358 static inline void set_tx_desc_rts_rate_fb_limit(__le32 *__txdesc, u32 __value)
360 le32p_replace_bits((__txdesc + 5), __value, GENMASK(16, 13));
364 /* Dword 6 */
365 static inline void set_tx_desc_max_agg_num(__le32 *__txdesc, u32 __value)
367 le32p_replace_bits((__txdesc + 6), __value, GENMASK(15, 11));
371 /* Dword 7 */
372 static inline void set_tx_desc_tx_desc_checksum(__le32 *__txdesc, u32 __value)
374 le32p_replace_bits((__txdesc + 7), __value, GENMASK(15, 0));
378 int rtl8192cu_endpoint_mapping(struct ieee80211_hw *hw);
379 u16 rtl8192cu_mq_to_hwq(__le16 fc, u16 mac80211_queue_index);
380 bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
381 struct rtl_stats *stats,
382 struct ieee80211_rx_status *rx_status,
383 u8 *p_desc, struct sk_buff *skb);
384 void rtl8192cu_rx_hdl(struct ieee80211_hw *hw, struct sk_buff * skb);
385 void rtl8192c_tx_cleanup(struct ieee80211_hw *hw, struct sk_buff *skb);
386 int rtl8192c_tx_post_hdl(struct ieee80211_hw *hw, struct urb *urb,
387 struct sk_buff *skb);
388 struct sk_buff *rtl8192c_tx_aggregate_hdl(struct ieee80211_hw *,
389 struct sk_buff_head *);
390 void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
391 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
392 u8 *pbd_desc_tx, struct ieee80211_tx_info *info,
393 struct ieee80211_sta *sta,
394 struct sk_buff *skb,
395 u8 queue_index,
396 struct rtl_tcb_desc *tcb_desc);
397 void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 *pdesc,
398 u32 buffer_len, bool ispspoll);
399 void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
400 u8 *pdesc, bool b_firstseg,
401 bool b_lastseg, struct sk_buff *skb);
403 #endif