1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright (c) 2011 Realtek Semiconductor Corp. */
3 
4 #ifndef __INC_RA_H
5 #define __INC_RA_H
6 /* Module Name: RateAdaptive.h
7  * Abstract: Prototype of RA and related data structure.
8  */
9 
10 #include <linux/bitfield.h>
11 
12 /*  Rate adaptive define */
13 #define	PERENTRY	23
14 #define	RETRYSIZE	5
15 #define	RATESIZE	28
16 #define	TX_RPT2_ITEM_SIZE	8
17 
18 /*  TX report 2 format in Rx desc */
19 #define GET_TX_RPT2_DESC_PKT_LEN_88E(__rxstatusdesc)		\
20 	le32_get_bits(*(__le32 *)__rxstatusdesc, GENMASK(8, 0))
21 #define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__rxstatusdesc)	\
22 	le32_to_cpu((*(__le32 *)(__rxstatusdesc + 16))
23 #define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__rxstatusdesc)	\
24 	le32_to_cpu((*(__le32 *)(__rxstatusdesc + 20))
25 
26 #define GET_TX_REPORT_TYPE1_RERTY_0(__paddr)			\
27 	le16_get_bits(*(__le16 *)__paddr, GENMASK(15, 0))
28 #define GET_TX_REPORT_TYPE1_RERTY_1(__paddr)			\
29 	LE_BITS_TO_1BYTE(__paddr + 2, 0, 8)
30 #define GET_TX_REPORT_TYPE1_RERTY_2(__paddr)			\
31 	LE_BITS_TO_1BYTE(__paddr + 3, 0, 8)
32 #define GET_TX_REPORT_TYPE1_RERTY_3(__paddr)			\
33 	LE_BITS_TO_1BYTE(__paddr + 4, 0, 8)
34 #define GET_TX_REPORT_TYPE1_RERTY_4(__paddr)			\
35 	LE_BITS_TO_1BYTE(__paddr + 5, 0, 8)
36 #define GET_TX_REPORT_TYPE1_DROP_0(__paddr)			\
37 	LE_BITS_TO_1BYTE(__paddr + 6, 0, 8)
38 /*  End rate adaptive define */
39 
40 void ODM_RASupport_Init(struct odm_dm_struct *dm_odm);
41 
42 int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm);
43 
44 int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 MacID);
45 
46 u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 MacID);
47 
48 u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 MacID);
49 
50 u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 MacID);
51 void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 MacID,
52 				 u8 RateID, u32 RateMask,
53 				 u8 SGIEnable);
54 
55 void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid,
56 			  u8 rssi);
57 
58 void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm,
59 			       u8 *txrpt_buf, u16 txrpt_len,
60 			       u32 validentry0, u32 validentry1);
61 
62 void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime);
63 
64 #endif
65