Files
kunlun/plc/halmac/inc/rf_rate_control.h
2024-09-28 14:24:04 +08:00

174 lines
7.3 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#include "os_utils_api.h"
#include "iot_io.h"
#include "iot_dbglog_api.h"
#include "iot_dbglog_parser.h"
#include "iot_errno_api.h"
#include "mac_peer.h"
#include "mac_rf_vdev.h"
#include "mpdu_header.h"
#include "cpl_types_api.h"
#include "rate_control.h"
#include "phy_txrx_pwr.h"
#define RF_RA_CON_NOSACK_PENALTY_CNT_THRE 5
#define RF_RA_CON_NOSACK_PENALTY_SNR_STEP 6
#define RF_RA_CON_SACKERR_PENALTY_CNT_THRE 2
#define RF_RA_CON_SACKERR_PENALTY_SNR_STEP 6
#define RF_RA_LOW_THRE_SNR_VAL 0
#if HPLC_RF_DEV_SUPPORT
/**
*@brief : mac_rf_data_get_rate mac rf data get rate info
*@param : msdu_len msdu length
*@param : option option. PHY_RF_OPTIONXXX
*@param : is_bcast is bcast
*@param : blkz block size id output
*@param : phr_mcs phy header mcs output
*@param : mcs mcs output
*@param : retry_cnt retry_cnt
*@param : dtei dtei
*@return : 0
*/
uint32_t mac_rf_data_get_rate(uint32_t msdu_len, uint32_t option,
uint8_t is_bcast, uint8_t *blkz, uint8_t *phr_mcs, uint8_t *mcs,
uint32_t retry_cnt, tei_t dtei)
;
/**
*@brief : mac_rf_bcn_get_rate mac rf bcn get rate info
*@param : bcn_len beacon len
*@param : option option. PHY_RF_OPTIONXXX
*@param : is_csma csma slot tx or not
*@param : slot_dur slot during time. unit: 1us
*@param : blkz block size id output
*@param : phr_mcs phy header mcs output
*@param : mcs mcs output
*@return : 0
*/
uint32_t mac_rf_bcn_get_rate(uint32_t bcn_len, uint32_t option, uint8_t is_csma,
uint32_t slot_dur, uint8_t *blkz, uint8_t *phr_mcs, uint8_t *mcs);
/**
*@brief : mac_rf_rate_ctxt_init rf rate context init
*@param : peer pointer to peer context
*@return : 0
*/
uint32_t mac_rf_rate_ctxt_init(mac_peer_t *peer);
/**
*@brief : mac_rf_rate_update rf rate update
*@param : peer_in which peer context to update
*@param : arg argument pointer of rx_fc_msg_t type
*@return : 0
*/
uint32_t mac_rf_rate_update(void *peer_in, void *arg);
/**
*@brief : rf_ra_init rf rate init
*@param : rf_vdev pointer of rf vdev
*@param : ena_ra enable/disable rate control
*@return : 0
*/
uint32_t rf_ra_init(mac_rf_vdev_t * rf_vdev, uint32_t ena_ra);
/**
*@brief : rf_ra_add_no_sack_cnt rf rate add count when no sack
*@param : ra pointer of ra context
*@return : none
*/
void rf_ra_add_no_sack_cnt(rate_info_t *ra);
/**
*@brief : rf_ra_clr_no_sack_cnt clear rf no sack count
*@param : ra pointer of ra context
*@return : none
*/
void rf_ra_clr_no_sack_cnt(rate_info_t *ra);
/**
*@brief : rf_ra_inc_con_sack_err_cnt rf continuously sack err count increase
*@param : ra pointer of ra context
*@return : none
*/
void rf_ra_inc_con_sack_err_cnt(rate_info_t *ra);
/**
*@brief : rf_ra_clr_con_sack_err_cnt clear rf continuously sack err count
*@param : ra pointer of ra context
*@return : none
*/
void rf_ra_clr_con_sack_err_cnt(rate_info_t *ra);
#else /* HPLC_RF_DEV_SUPPORT */
#define mac_rf_data_get_rate(msdu_len, option, is_bcast, blkz, \
phr_mcs, mcs, retry_cnt, dtei) \
do { \
(void)msdu_len; (void)is_bcast; (void)is_bcast; (void)blkz; \
(void)phr_mcs; (void)mcs; (void)retry_cnt; (void)dtei; \
} while(0);
#define mac_rf_bcn_get_rate(bcn_len, option, is_csma, \
slot_dur, blkz, phr_mcs, mcs) \
do { \
(void)bcn_len; (void)option; (void)is_csma; (void)slot_dur; \
(void)blkz; (void)phr_mcs; (void)mcs; \
} while(0);
#define mac_rf_rate_ctxt_init(peer) (void)ERR_NOSUPP; \
do { \
(void)(peer); \
} while(0);
#define mac_rf_rate_update(peer_in, arg) ERR_NOSUPP; \
do { \
(void)(peer_in); \
(void)(arg); \
} while(0);
#define rf_ra_init(vdev, ena_ra) ERR_NOSUPP; \
do { \
(void)(vdev); \
(void)(ena_ra); \
} while(0);
#define rf_ra_add_no_sack_cnt(ra) \
do { \
(void)(ra); \
} while(0);
#define rf_ra_add_clr_no_sack_cnt(ra) \
do { \
(void)(ra); \
} while(0);
#define rf_ra_inc_con_sack_err_cnt(ra) \
do { \
(void)(ra); \
} while(0);
#define rf_ra_clr_con_sack_err_cnt(ra) \
do { \
(void)(ra); \
} while(0);
#endif /* HPLC_RF_DEV_SUPPORT */