244 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			244 lines
		
	
	
		
			6.4 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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								#ifndef MAC_TXQ_HW_H
							 | 
						||
| 
								 | 
							
								#define MAC_TXQ_HW_H
							 | 
						||
| 
								 | 
							
								#include "os_types.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define MAX_MAC_TXQ_NUM     24  /* 0 - 23 */
							 | 
						||
| 
								 | 
							
								#define MAX_MAC_DCU_NUM     5   /* 0 - 4 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define HWQ_DEBUG_MODE          1
							 | 
						||
| 
								 | 
							
								#define HWQ_SCHE_MODE           0
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_rx_rifs_tmr_set() -      set rx rifs timer
							 | 
						||
| 
								 | 
							
								 * @param: rx_tmr       rx RIFS timer, unit: 1us
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define mac_rx_rifs_tmr_set(rx_tmr)     mac_tx_rifs_tmr_set(rx_tmr)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_tx_cfg_bcn_miss_num() -  set hw rx mode both sr and qr
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_rx_sr_qr_mode_set();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_tx_cfg_bcn_miss_num() -  config tx beacon miss num
							 | 
						||
| 
								 | 
							
								 * @param: num --    miss beacon num
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_tx_cfg_bcn_miss_num(uint32_t num);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cfg_phy_tx_phase_select() -  force tx phase
							 | 
						||
| 
								 | 
							
								 * @param: enable --    1:enable 0:disable
							 | 
						||
| 
								 | 
							
								 * @param: phase --     0:all phase, 1:A , 2:B , 3:C
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cfg_phy_tx_phase_select(uint32_t enable, uint32_t phase);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								* @brief mac_cfg_phy_tx_underflow_force() - force phy tx underflow.
							 | 
						||
| 
								 | 
							
								*
							 | 
						||
| 
								 | 
							
								* @param        none
							 | 
						||
| 
								 | 
							
								*
							 | 
						||
| 
								 | 
							
								* @return       none
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_cfg_phy_tx_underflow_force(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* set the cfg of the specific qid */
							 | 
						||
| 
								 | 
							
								void mac_txq_cfg(uint32_t qid, uint32_t cap, \
							 | 
						||
| 
								 | 
							
								    uint32_t is_csma);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void *mac_txq_get_curr_desc_ptr(uint8_t is_role_cco, uint8_t is_bcn);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* enable the queue with the first tx desc */
							 | 
						||
| 
								 | 
							
								void mac_txq_enable(uint32_t qid, void *tx_desc);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* if enable, return none-zero
							 | 
						||
| 
								 | 
							
								 * else, return 0
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_txq_is_enable(uint32_t qid);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* get txq tx comp status bitmap */
							 | 
						||
| 
								 | 
							
								uint32_t mac_txq_get_txcomp_status();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* clr the hwq txcomp */
							 | 
						||
| 
								 | 
							
								void mac_txq_clr_txcomp_status(uint32_t hwqid);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* enable/disable txq dbg mode */
							 | 
						||
| 
								 | 
							
								void mac_txq_set_dbg_mode(uint32_t is_dbg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* set the txq poll interval, us unit */
							 | 
						||
| 
								 | 
							
								uint32_t mac_txq_set_poll_intval(uint32_t intvl_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* set the packet in hwq immediately */
							 | 
						||
| 
								 | 
							
								uint32_t mac_txq_trigger_send(uint32_t qid);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t mac_tx_hw_get_bcn_swcrc_cfg();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_tx_hw_set_bcn_swcrc_cfg(uint32_t is_by_sw);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* check if dbg mode */
							 | 
						||
| 
								 | 
							
								uint32_t mac_txq_is_dbg_mode();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_tx_cfg_start_desc_timeout(uint32_t enable, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_tx_cfg_end_desc_timeout(uint32_t enable, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_tx_cfg_phy_tx_timeout(uint32_t enable, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_tx_cfg_aes_key_timeout(uint32_t enable, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_tx_cfg_buf_timeout(uint32_t enable, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_tx_cfg_desc_timeout(uint32_t enable, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_txq_cfg_tdma_do_cca(uint32_t enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_txq_clr_all_txcomp_status(uint32_t bitmap);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t mac_txq_is_csma(uint32_t qid);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_set_slottime(uint32_t cap, uint32_t time_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_set_tx_bts_dly(int32_t delay_ntb);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_set_min_backoff_slotnum() -
							 | 
						||
| 
								 | 
							
								 *          set 2^x of min backoff be value
							 | 
						||
| 
								 | 
							
								 * @param tmr:    2^(_2_be)
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_set_min_backoff_slotnum(uint32_t _2_be);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_tx_rifs_tmr_set   set tx RIFS time.
							 | 
						||
| 
								 | 
							
								 * @param tmr:    RIFS time(us)
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_tx_rifs_tmr_set(uint32_t tmr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_cfg_tx_rifs_set   update tx rifs conifg
							 | 
						||
| 
								 | 
							
								 * @param tmr_us:       tx RIFS time(us)
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_cfg_tx_rifs_set(uint32_t tmr_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_cfg_tx_rifs_get   get tx rifs conifg
							 | 
						||
| 
								 | 
							
								 * @return              tx RIFS time(us)
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_cfg_tx_rifs_get(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_cfg_rx_rifs_set   update rx rifs conifg
							 | 
						||
| 
								 | 
							
								 * @param tmr_us:       rx RIFS time(us)
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_cfg_rx_rifs_set(uint32_t tmr_us);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_cfg_rx_rifs_get   get rx rifs conifg
							 | 
						||
| 
								 | 
							
								 * @return      rx RIFS time(us)
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_cfg_rx_rifs_get(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_cfg_cifs_tmr_init     init cifs config
							 | 
						||
| 
								 | 
							
								 * @param proto:        current protocol, see PLC_PROTO_TYPE_XXX
							 | 
						||
| 
								 | 
							
								 * @return              none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_cfg_cifs_tmr_init(uint32_t proto);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_cfg_rifs_tmr_init     init rifs config
							 | 
						||
| 
								 | 
							
								 * @param is_cert:      0 - normal mode case, others - cert mode case
							 | 
						||
| 
								 | 
							
								 * @param proto:        current protocol, see PLC_PROTO_TYPE_XXX
							 | 
						||
| 
								 | 
							
								 * @return              none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_cfg_rifs_tmr_init(uint8_t is_cert, uint32_t proto);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_set_fc_fl_cfg_status() - set sw cfg fc frame len
							 | 
						||
| 
								 | 
							
								 * @param flag 0 : hw cfg, 1 : sw cfg
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_set_fc_fl_cfg_status(uint8_t flag);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_get_fc_fl_cfg_status() - get fc frame len cfg status
							 | 
						||
| 
								 | 
							
								 * @return  0 : hw cfg, 1 : sw cfg
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_get_fc_fl_cfg_status();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_get_tx_cifs() - get tx cifs value
							 | 
						||
| 
								 | 
							
								 * @return cifs value
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_get_tx_cifs();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_get_tx_rifs() - get tx rifs value
							 | 
						||
| 
								 | 
							
								 * @return rifs value
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_get_tx_rifs();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* @brief mac_get_tx_bifs() - get tx bifs value
							 | 
						||
| 
								 | 
							
								 * @param proto             current porotocol, see PLC_PROTO_TYPE_XXX
							 | 
						||
| 
								 | 
							
								 * @return:      bifs value - us
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_get_tx_bifs(uint32_t proto);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set cifs time
							 | 
						||
| 
								 | 
							
								 * @param tmr - [value of us unit time]
							 | 
						||
| 
								 | 
							
								 * @return - [none]
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_tx_cifs_tmr_set(uint32_t tmr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set bifs time
							 | 
						||
| 
								 | 
							
								 * @param proto     [current porotocol, see PLC_PROTO_TYPE_XXX]
							 | 
						||
| 
								 | 
							
								 * @param tmr       [value of us unit time]
							 | 
						||
| 
								 | 
							
								 * @return - [none]
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void mac_tx_bifs_tmr_set(uint32_t proto, uint32_t tmr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_tx_hw_set_delay  set count, and used to sw delay .
							 | 
						||
| 
								 | 
							
								 *@param tmr                [delay time]
							 | 
						||
| 
								 | 
							
								 *@exception                [none.]
							 | 
						||
| 
								 | 
							
								 *@return                   [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_tx_hw_set_delay(uint32_t tmr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_tx_hw_get_delay  get count, used to sw delay.
							 | 
						||
| 
								 | 
							
								 *@exception                [none.]
							 | 
						||
| 
								 | 
							
								 *@return                   [get time]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								uint32_t mac_tx_hw_get_delay();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief mac_get_sche_rx_phase  get schedule rx phase
							 | 
						||
| 
								 | 
							
								 * @param tmr - [value of us unit time]
							 | 
						||
| 
								 | 
							
								 * @return - [rx phase]
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t mac_get_sche_rx_phase();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif // !MAC_TXQ_HW_H
							 |