1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
4 #ifndef __REALTEK_92S_DEF_H__
5 #define __REALTEK_92S_DEF_H__
7 #define RX_MPDU_QUEUE 0
10 #define SHORT_SLOT_TIME 9
11 #define NON_SHORT_SLOT_TIME 20
13 /* Queue Select Value in TxDesc */
18 #define QSLT_BEACON 0x10
19 #define QSLT_HIGH 0x11
20 #define QSLT_MGNT 0x12
24 #define TX_DESC_SIZE_RTL8192S (16 * 4)
25 #define TX_CMDDESC_SIZE_RTL8192S (16 * 4)
27 /* macros to read/write various fields in RX or TX descriptors */
30 static inline void set_tx_desc_pkt_size(__le32
*__pdesc
, u32 __val
)
32 le32p_replace_bits(__pdesc
, __val
, GENMASK(15, 0));
35 static inline void set_tx_desc_offset(__le32
*__pdesc
, u32 __val
)
37 le32p_replace_bits(__pdesc
, __val
, GENMASK(23, 16));
40 static inline void set_tx_desc_last_seg(__le32
*__pdesc
, u32 __val
)
42 le32p_replace_bits(__pdesc
, __val
, BIT(26));
45 static inline void set_tx_desc_first_seg(__le32
*__pdesc
, u32 __val
)
47 le32p_replace_bits(__pdesc
, __val
, BIT(27));
50 static inline void set_tx_desc_linip(__le32
*__pdesc
, u32 __val
)
52 le32p_replace_bits(__pdesc
, __val
, BIT(28));
55 static inline void set_tx_desc_own(__le32
*__pdesc
, u32 __val
)
57 le32p_replace_bits(__pdesc
, __val
, BIT(31));
60 static inline u32
get_tx_desc_own(__le32
*__pdesc
)
62 return le32_get_bits(*(__pdesc
), BIT(31));
66 static inline void set_tx_desc_macid(__le32
*__pdesc
, u32 __val
)
68 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(4, 0));
71 static inline void set_tx_desc_queue_sel(__le32
*__pdesc
, u32 __val
)
73 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(12, 8));
76 static inline void set_tx_desc_non_qos(__le32
*__pdesc
, u32 __val
)
78 le32p_replace_bits((__pdesc
+ 1), __val
, BIT(16));
81 static inline void set_tx_desc_sec_type(__le32
*__pdesc
, u32 __val
)
83 le32p_replace_bits((__pdesc
+ 1), __val
, GENMASK(23, 22));
87 static inline void set_tx_desc_rsvd_macid(__le32
*__pdesc
, u32 __val
)
89 le32p_replace_bits((__pdesc
+ 2), __val
, GENMASK(28, 24));
92 static inline void set_tx_desc_agg_enable(__le32
*__pdesc
, u32 __val
)
94 le32p_replace_bits((__pdesc
+ 2), __val
, BIT(29));
98 static inline void set_tx_desc_seq(__le32
*__pdesc
, u32 __val
)
100 le32p_replace_bits((__pdesc
+ 3), __val
, GENMASK(27, 16));
104 static inline void set_tx_desc_rts_rate(__le32
*__pdesc
, u32 __val
)
106 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(5, 0));
109 static inline void set_tx_desc_cts_enable(__le32
*__pdesc
, u32 __val
)
111 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(11));
114 static inline void set_tx_desc_rts_enable(__le32
*__pdesc
, u32 __val
)
116 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(12));
119 static inline void set_tx_desc_ra_brsr_id(__le32
*__pdesc
, u32 __val
)
121 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(15, 13));
124 static inline void set_tx_desc_txht(__le32
*__pdesc
, u32 __val
)
126 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(16));
129 static inline void set_tx_desc_tx_short(__le32
*__pdesc
, u32 __val
)
131 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(17));
134 static inline void set_tx_desc_tx_bandwidth(__le32
*__pdesc
, u32 __val
)
136 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(18));
139 static inline void set_tx_desc_tx_sub_carrier(__le32
*__pdesc
, u32 __val
)
141 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(20, 19));
144 static inline void set_tx_desc_rts_short(__le32
*__pdesc
, u32 __val
)
146 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(25));
149 static inline void set_tx_desc_rts_bandwidth(__le32
*__pdesc
, u32 __val
)
151 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(26));
154 static inline void set_tx_desc_rts_sub_carrier(__le32
*__pdesc
, u32 __val
)
156 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(28, 27));
159 static inline void set_tx_desc_rts_stbc(__le32
*__pdesc
, u32 __val
)
161 le32p_replace_bits((__pdesc
+ 4), __val
, GENMASK(30, 29));
164 static inline void set_tx_desc_user_rate(__le32
*__pdesc
, u32 __val
)
166 le32p_replace_bits((__pdesc
+ 4), __val
, BIT(31));
170 static inline void set_tx_desc_packet_id(__le32
*__pdesc
, u32 __val
)
172 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(8, 0));
175 static inline void set_tx_desc_tx_rate(__le32
*__pdesc
, u32 __val
)
177 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(14, 9));
180 static inline void set_tx_desc_data_rate_fb_limit(__le32
*__pdesc
, u32 __val
)
182 le32p_replace_bits((__pdesc
+ 5), __val
, GENMASK(20, 16));
186 static inline void set_tx_desc_tx_buffer_size(__le32
*__pdesc
, u32 __val
)
188 le32p_replace_bits((__pdesc
+ 7), __val
, GENMASK(15, 0));
192 static inline void set_tx_desc_tx_buffer_address(__le32
*__pdesc
, u32 __val
)
194 *(__pdesc
+ 8) = cpu_to_le32(__val
);
197 static inline u32
get_tx_desc_tx_buffer_address(__le32
*__pdesc
)
199 return le32_to_cpu(*((__pdesc
+ 8)));
203 static inline void set_tx_desc_next_desc_address(__le32
*__pdesc
, u32 __val
)
205 *(__pdesc
+ 9) = cpu_to_le32(__val
);
208 /* Because the PCI Tx descriptors are chaied at the
209 * initialization and all the NextDescAddresses in
210 * these descriptors cannot not be cleared (,or
211 * driver/HW cannot find the next descriptor), the
212 * offset 36 (NextDescAddresses) is reserved when
213 * the desc is cleared. */
214 #define TX_DESC_NEXT_DESC_OFFSET 36
215 #define CLEAR_PCI_TX_DESC_CONTENT(__pdesc, _size) \
216 memset(__pdesc, 0, min_t(size_t, _size, TX_DESC_NEXT_DESC_OFFSET))
219 #define RX_STATUS_DESC_SIZE 24
220 #define RX_DRV_INFO_SIZE_UNIT 8
223 static inline void set_rx_status_desc_pkt_len(__le32
*__pdesc
, u32 __val
)
225 le32p_replace_bits(__pdesc
, __val
, GENMASK(13, 0));
228 static inline void set_rx_status_desc_eor(__le32
*__pdesc
, u32 __val
)
230 le32p_replace_bits(__pdesc
, __val
, BIT(30));
233 static inline void set_rx_status_desc_own(__le32
*__pdesc
, u32 __val
)
235 le32p_replace_bits(__pdesc
, __val
, BIT(31));
238 static inline u32
get_rx_status_desc_pkt_len(__le32
*__pdesc
)
240 return le32_get_bits(*(__pdesc
), GENMASK(13, 0));
243 static inline u32
get_rx_status_desc_crc32(__le32
*__pdesc
)
245 return le32_get_bits(*(__pdesc
), BIT(14));
248 static inline u32
get_rx_status_desc_icv(__le32
*__pdesc
)
250 return le32_get_bits(*(__pdesc
), BIT(15));
253 static inline u32
get_rx_status_desc_drvinfo_size(__le32
*__pdesc
)
255 return le32_get_bits(*(__pdesc
), GENMASK(19, 16));
258 static inline u32
get_rx_status_desc_shift(__le32
*__pdesc
)
260 return le32_get_bits(*(__pdesc
), GENMASK(25, 24));
263 static inline u32
get_rx_status_desc_phy_status(__le32
*__pdesc
)
265 return le32_get_bits(*(__pdesc
), BIT(26));
268 static inline u32
get_rx_status_desc_swdec(__le32
*__pdesc
)
270 return le32_get_bits(*(__pdesc
), BIT(27));
273 static inline u32
get_rx_status_desc_own(__le32
*__pdesc
)
275 return le32_get_bits(*(__pdesc
), BIT(31));
279 static inline u32
get_rx_status_desc_paggr(__le32
*__pdesc
)
281 return le32_get_bits(*(__pdesc
+ 1), BIT(14));
284 static inline u32
get_rx_status_desc_faggr(__le32
*__pdesc
)
286 return le32_get_bits(*(__pdesc
+ 1), BIT(15));
290 static inline u32
get_rx_status_desc_rx_mcs(__le32
*__pdesc
)
292 return le32_get_bits(*(__pdesc
+ 3), GENMASK(5, 0));
295 static inline u32
get_rx_status_desc_rx_ht(__le32
*__pdesc
)
297 return le32_get_bits(*(__pdesc
+ 3), BIT(6));
300 static inline u32
get_rx_status_desc_splcp(__le32
*__pdesc
)
302 return le32_get_bits(*(__pdesc
+ 3), BIT(8));
305 static inline u32
get_rx_status_desc_bw(__le32
*__pdesc
)
307 return le32_get_bits(*(__pdesc
+ 3), BIT(9));
311 static inline u32
get_rx_status_desc_tsfl(__le32
*__pdesc
)
313 return le32_to_cpu(*((__pdesc
+ 5)));
317 static inline void set_rx_status__desc_buff_addr(__le32
*__pdesc
, u32 __val
)
319 *(__pdesc
+ 6) = cpu_to_le32(__val
);
322 static inline u32
get_rx_status_desc_buff_addr(__le32
*__pdesc
)
324 return le32_to_cpu(*(__pdesc
+ 6));
327 #define SE_RX_HAL_IS_CCK_RATE(_pdesc)\
328 (get_rx_status_desc_rx_mcs(_pdesc) == DESC_RATE1M || \
329 get_rx_status_desc_rx_mcs(_pdesc) == DESC_RATE2M || \
330 get_rx_status_desc_rx_mcs(_pdesc) == DESC_RATE5_5M ||\
331 get_rx_status_desc_rx_mcs(_pdesc) == DESC_RATE11M)
334 RF_OP_BY_SW_3WIRE
= 0,
339 enum ic_inferiority
{
340 IC_INFERIORITY_A
= 0,
341 IC_INFERIORITY_B
= 1,
346 FW_CMD_DIG_ENABLE
= 0,
347 FW_CMD_DIG_DISABLE
= 1,
349 FW_CMD_DIG_RESUME
= 3,
350 /* For High Power DM */
351 FW_CMD_HIGH_PWR_ENABLE
= 4,
352 FW_CMD_HIGH_PWR_DISABLE
= 5,
353 /* For Rate adaptive DM */
355 FW_CMD_RA_ACTIVE
= 7,
356 FW_CMD_RA_REFRESH_N
= 8,
357 FW_CMD_RA_REFRESH_BG
= 9,
359 /* For FW supported IQK */
360 FW_CMD_IQK_INIT
= 11,
361 /* Tx power tracking switch,
363 FW_CMD_TXPWR_TRACK_ENABLE
= 12,
364 /* Tx power tracking switch,
366 FW_CMD_TXPWR_TRACK_DISABLE
= 13,
367 /* Tx power tracking with thermal
368 * indication, for Normal driver */
369 FW_CMD_TXPWR_TRACK_THERMAL
= 14,
370 FW_CMD_PAUSE_DM_BY_SCAN
= 15,
371 FW_CMD_RESUME_DM_BY_SCAN
= 16,
372 FW_CMD_RA_REFRESH_N_COMB
= 17,
373 FW_CMD_RA_REFRESH_BG_COMB
= 18,
374 FW_CMD_ANTENNA_SW_ENABLE
= 19,
375 FW_CMD_ANTENNA_SW_DISABLE
= 20,
376 /* Tx Status report for CCX from FW */
377 FW_CMD_TX_FEEDBACK_CCX_ENABLE
= 21,
378 /* Indifate firmware that driver
379 * enters LPS, For PS-Poll issue */
380 FW_CMD_LPS_ENTER
= 22,
381 /* Indicate firmware that driver
383 FW_CMD_LPS_LEAVE
= 23,
384 /* Set DIG mode to signal strength */
385 FW_CMD_DIG_MODE_SS
= 24,
386 /* Set DIG mode to false alarm. */
387 FW_CMD_DIG_MODE_FA
= 25,
388 FW_CMD_ADD_A2_ENTRY
= 26,
389 FW_CMD_CTRL_DM_BY_DRIVER
= 27,
390 FW_CMD_CTRL_DM_BY_DRIVER_NEW
= 28,
391 FW_CMD_PAPE_CONTROL
= 29,
392 FW_CMD_IQK_ENABLE
= 30,
395 /* Driver info contain PHY status
396 * and other variabel size info
397 * PHY Status content as below
424 struct phy_sts_cck_8192s_t
{