375 lines
10 KiB
C
Executable File
375 lines
10 KiB
C
Executable File
/****************************************************************************
|
|
|
|
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_CERT_TEST_H_
|
|
#define _MAC_CERT_TEST_H_
|
|
|
|
#include "mac_cert_test_api.h"
|
|
#include "mac_rawdata_hw.h"
|
|
#include "iot_uart_api.h"
|
|
#include "iot_uart_h.h"
|
|
#include "mac_dsr.h"
|
|
#include "tx_pb_start.h"
|
|
#include "rx_mpdu_start.h"
|
|
#include "tx_mpdu_start.h"
|
|
#if HPLC_RF_DEV_SUPPORT
|
|
#include "rf_tx_mpdu_desc.h"
|
|
#include "rf_rx_mpdu_desc.h"
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define MT_MODE_HWQ 0 //hwq0
|
|
|
|
#define DIS_RAWDATA_MODE 0
|
|
#define EN_RAWDATA_MODE 1
|
|
|
|
#define CERT_SUPPORT 1
|
|
|
|
#define CIFS_DELAY_TMR 3750 //CIFS delay time 120us
|
|
|
|
#define MAC_CERT_NID_MAX 0x0f
|
|
|
|
#define MAC_CERT_WAR_TX_BUF_LEN 1024
|
|
|
|
#define MAC_CERT_SPUR_ATT_50DB 1
|
|
#define MAC_CERT_SPUR_ATT_60DB 2
|
|
#define MAC_CERT_SPUR_ATT_70DB 3
|
|
#define MAC_CERT_SPUR_ATT_80DB 4
|
|
|
|
#define MAC_CERT_WAR_WORK_ATT MAC_CERT_SPUR_ATT_70DB
|
|
|
|
/* long interval 5.4 S */
|
|
#define MAC_CERT_WAR_TRANS_LONG_INTV_MS 5400
|
|
/* long interval 500 ms */
|
|
#define MAC_CERT_WAR_TRANS_SHORT_INTV_MS 500
|
|
|
|
#define MAC_CERT_1500MS_NTB 37500000
|
|
#define MAC_CERT_6000MS_NTB 150000000
|
|
|
|
#define MAC_CERT_TMR_INIT_STS 1
|
|
#define MAC_CERT_TMR_LONG_50DB_STS 2
|
|
#define MAC_CERT_TMR_LONG_60DB_STS 3
|
|
#define MAC_CERT_TMR_LONG_70DB_STS 4
|
|
#define MAC_CERT_TMR_LONG_80DB_STS 5
|
|
#define MAC_CERT_TMR_LONG_90DB_STS 6
|
|
#define MAC_CERT_TMR_LONG_100DB_STS 7
|
|
#define MAC_CERT_TMR_SHORT_50DB_STS 8
|
|
#define MAC_CERT_TMR_SHORT_60DB_STS 9
|
|
#define MAC_CERT_TMR_SHORT_70DB_STS 10
|
|
#define MAC_CERT_TMR_SHORT_80DB_STS 11
|
|
#define MAC_CERT_TMR_SHORT_90DB_STS 12
|
|
#define MAC_CERT_TMR_SHORT_100DB_STS 13
|
|
|
|
/*
|
|
* mac_recv_msdu_mt_func_t() - call back for direct transmission use uart .
|
|
*/
|
|
typedef void (*mac_recv_msdu_mt_func_t)(void *arg, iot_pkt_t *msdu_buf);
|
|
|
|
typedef struct _mac_mt_tx_ctxt {
|
|
uint8_t cert_test_support : 1,
|
|
g_mt_mode_sel : 4,
|
|
g_mt_mode_flag : 1,
|
|
g_lp_ppm_hold : 1,
|
|
g_lp_not_first_cal_ppm : 1;
|
|
/* flag to mark if HPLC to RF conversion behavior in progress */
|
|
uint8_t hplc2rf_ing : 1,
|
|
/* reserved for further use */
|
|
rsvd : 7;
|
|
uint8_t band_id;
|
|
uint8_t tonemask_id;
|
|
/* security test mode, see CERT_TEST_SEC_MODE_XXX */
|
|
uint8_t sec_mode;
|
|
uint8_t pb_header[4];
|
|
uint32_t pb_crc[4];
|
|
/* record loopback mode cal ppm, uint 1 ppm */
|
|
int8_t rcd_lp_ppm;
|
|
/* fc for rawdata mode */
|
|
fc_trans_msg *p_msg;
|
|
|
|
/* callback for msdu for ransparent transfer mode */
|
|
mac_recv_msdu_mt_func_t mt_msdu_tx_funt;
|
|
|
|
/* uart handle */
|
|
iot_uart_h mt_uart_h;
|
|
|
|
/* allocate the pkt for transparent transfer mode */
|
|
iot_pkt_t *data_pkt;
|
|
|
|
/* temporary the callback of dsr when entry cert test mode */
|
|
mac_dsr_func_t dsr_tmp;
|
|
|
|
/* temporary rx mpdu when receive first pb */
|
|
rx_mpdu_start *mpdu_st_tmp;
|
|
|
|
/* allocate mpdu desc for loopback */
|
|
tx_mpdu_start *mpdu;
|
|
|
|
/* allocate end desc for loopback */
|
|
tx_mpdu_end *end;
|
|
|
|
/* allocate pb_list desc for loopback */
|
|
tx_pb_start *pb_st[4];
|
|
|
|
/* record the num of the pb for loopback */
|
|
uint8_t pb_seq;
|
|
/*record beacon tx phase -> cco phase*/
|
|
uint8_t rx_phase;
|
|
int8_t raw_snr;
|
|
|
|
/* if rx the first pb */
|
|
uint8_t rx_first_pb;
|
|
/* if all pb loopbacked */
|
|
uint8_t all_pb_loopbacked;
|
|
/* rx pb count for loopback */
|
|
uint8_t rx_pb_cnt;
|
|
/* sw buf offset for loopback */
|
|
uint32_t sw_buf_offset;
|
|
|
|
/* tmp mpdu fc storage */
|
|
uint32_t tmp_fc[4];
|
|
|
|
#if HPLC_RF_DEV_SUPPORT
|
|
/* temporary rf rx mpdu when receive first pb */
|
|
rf_rx_mpdu_start *rf_rx_mpdu;
|
|
|
|
/* allocate mpdu desc for loopback */
|
|
rf_tx_mpdu_start *rf_mpdu;
|
|
|
|
/* allocate end desc for loopback */
|
|
rf_tx_mpdu_end *rf_end;
|
|
|
|
/* allocate pb_list desc for loopback */
|
|
rf_tx_pb_start *rf_pb_st;
|
|
|
|
/* sw buf offset for loopback */
|
|
uint32_t rf_sw_buf_offset;
|
|
uint8_t phr_mcs;
|
|
uint8_t pld_mcs;
|
|
uint8_t pb_idx;
|
|
#endif
|
|
timer_id_t cert_war_tmr;
|
|
uint32_t war_trans_cnt;
|
|
|
|
iot_pkt_t *war_data;
|
|
uint32_t cert_spur_war_en : 1,
|
|
spur_1m_exist : 1,
|
|
spur_3m_exist : 1,
|
|
spur_6m_exist : 1,
|
|
spur_500k_exist : 1,
|
|
spur_2m_exist : 1,
|
|
spur_5m_exist : 1,
|
|
war_tmr_flg : 1,
|
|
/* att = 1 -> MAC_CERT_SPUR_ATT_50DB
|
|
* att = 2 -> MAC_CERT_SPUR_ATT_60DB
|
|
* att = 3 -> MAC_CERT_SPUR_ATT_70DB
|
|
* att = 4 -> MAC_CERT_SPUR_ATT_80DB
|
|
*/
|
|
spur_att_cnt : 8,
|
|
spur_1m_first : 1,
|
|
spur_3m_first : 1,
|
|
spur_6m_first : 1,
|
|
spur_500k_first : 1,
|
|
spur_2m_first : 1,
|
|
spur_5m_first : 1,
|
|
war_tmr_sts : 4,
|
|
orgin_trans_flag : 1,
|
|
rsev1 : 5;
|
|
uint32_t war_1m_ntb;
|
|
uint32_t war_3m_ntb;
|
|
uint32_t war_6m_ntb;
|
|
uint32_t war_500k_ntb;
|
|
uint32_t war_2m_ntb;
|
|
uint32_t war_5m_ntb;
|
|
uint8_t sof_50db_cnt;
|
|
uint8_t sof_60db_cnt;
|
|
uint8_t sof_train_cnt;
|
|
|
|
uint32_t cert_spike_war_en : 1,
|
|
spike_war_first : 1,
|
|
spike_att_first_rcd : 1,
|
|
spike_50db_ready_cnt : 8,
|
|
spike_nf : 8,
|
|
rsev2 : 13;
|
|
uint32_t spike_war_ntb;
|
|
|
|
uint32_t last_bcn_ntb;
|
|
uint8_t spike_pd_detect_en: 1,
|
|
spike_pd_detect_first: 1,
|
|
spike_detect_rxbcn_cnt : 6;
|
|
} mac_mt_tx_ctxt_t;
|
|
|
|
/*
|
|
* g_mt_ctxt - cert test mode globe value .
|
|
*/
|
|
extern mac_mt_tx_ctxt_t *g_mt_ctxt;
|
|
|
|
/*
|
|
* mac_cert_test_tonemast_cfg() - config tonemask id .
|
|
*/
|
|
uint32_t mac_cert_test_tonemast_cfg(uint8_t tonemask_id);
|
|
|
|
/*
|
|
* mac_cert_test_sec_mode_set() - set security mode
|
|
*/
|
|
uint32_t mac_cert_test_sec_mode_set(uint8_t sec_mode);
|
|
|
|
/*
|
|
* mac_cert_test_band_cfg() - config band id .
|
|
*/
|
|
uint32_t mac_cert_test_band_cfg(uint8_t band_id);
|
|
|
|
/*
|
|
* mac_cert_test_g_set() - config cert mode globe value .
|
|
*/
|
|
uint32_t mac_cert_test_g_set(uint8_t mt_mode_sel);
|
|
|
|
/*
|
|
* mac_cert_test_g_init() - cert test mode init .
|
|
*/
|
|
uint32_t mac_cert_test_g_init();
|
|
|
|
/*
|
|
* mac_cert_test_handle() - handle phy tran mode and phy return mode .
|
|
*/
|
|
uint32_t mac_cert_test_handle(void *pdev, iot_pkt_t *mt_pkt);
|
|
|
|
/*
|
|
* mac_rawdata_fc_send() - mac send pkt in rawdata mode .
|
|
*/
|
|
uint32_t mac_rawdata_fc_send(uint8_t *fc, uint8_t tmi, uint8_t ext_tmi);
|
|
|
|
/*
|
|
* mm_to_cert_switch() - mission mode switch to cert test mode .
|
|
* @param cert_mode_type: cert mode type
|
|
*/
|
|
uint32_t mm_to_cert_switch(uint8_t cert_mode_type);
|
|
|
|
/*
|
|
* cert_to_mm_switch() - cert_test mode switch to mission mode .
|
|
* @param cert_mode_type: cert mode type
|
|
*/
|
|
uint32_t cert_to_mm_switch(uint8_t cert_mode_type);
|
|
|
|
/*
|
|
* cert_mode_stop() - stop cert_test mode ,clear callback and g_mt_ctxt .
|
|
*/
|
|
uint32_t cert_mode_stop();
|
|
|
|
/*
|
|
* @brief fill_pb_hdr_crc_rawdata() - sw fill pb header and pb crc .
|
|
* @param pb: pb list
|
|
* @param pb_hdr_tlb pb header table
|
|
* @param pb_crc_tlb: pb crc table
|
|
*/
|
|
uint32_t fill_pb_hdr_crc_rawdata(tx_pb_start *pb, uint8_t *pb_hdr_tlb, \
|
|
uint32_t *pb_crc_tlb);
|
|
|
|
/*
|
|
* @brief mac_get_cert_test_mode() get cur cert test mode
|
|
* @return [0 - not cert test mode]
|
|
* [other - cur cert test mode]
|
|
*/
|
|
uint8_t mac_get_cert_test_mode();
|
|
|
|
/*
|
|
* @brief mac_get_cert_test_flag() get cur cert test flag
|
|
* @return [0 - not cert test mode]
|
|
* [1 - cur cert test mode]
|
|
*/
|
|
uint8_t mac_get_cert_test_flag();
|
|
|
|
/*
|
|
* @brief mac_cert_is_nid_valid() judge nid is a valid nid
|
|
* @return [1 - a valid nid]
|
|
* [0 - is not]
|
|
*/
|
|
uint8_t mac_cert_is_nid_valid(nid_t nid);
|
|
|
|
/*
|
|
* @brief mac_cert_war_trans_handle() war trans handle
|
|
* @return void.
|
|
*/
|
|
void mac_cert_war_trans_handle();
|
|
|
|
/*
|
|
* @brief mac_get_cert_war_flag() get cur cert test war flag
|
|
* @return [0 - disable cert test war]
|
|
* [1 - enable cert test war]
|
|
*/
|
|
uint8_t mac_get_cert_war_flag();
|
|
|
|
/*
|
|
* @brief mac_set_not_first_cal_lp_ppm() set notfirst cal lp ppm.
|
|
* @param is_not_first: is not first cal lp ppm.
|
|
* @return void.
|
|
*/
|
|
void mac_set_not_first_cal_lp_ppm(uint8_t is_not_first);
|
|
|
|
/*
|
|
* @brief mac_get_is_not_first_cal_lp_ppm()
|
|
* is not first cal lp ppm.
|
|
* @return is first cal lp ppm or not.
|
|
*/
|
|
uint8_t mac_get_is_not_first_cal_lp_ppm();
|
|
|
|
/*
|
|
* @brief mac_get_rcd_lp_ppm() mac get record lp ppm.
|
|
* @return record lp ppm.
|
|
*/
|
|
int8_t mac_get_rcd_lp_ppm();
|
|
|
|
/*
|
|
* @brief mac_set_rcd_lp_ppm() record lp ppm.
|
|
* @param lp_ppm: lp ppm.
|
|
* @return void.
|
|
*/
|
|
void mac_set_rcd_lp_ppm(int8_t lp_ppm);
|
|
|
|
/*
|
|
* @brief mac_get_lp_cal_ppm_is_hold() get cal ppm is hold.
|
|
* @return get cal ppm is hold or not.
|
|
*/
|
|
uint8_t mac_get_lp_cal_ppm_is_hold();
|
|
|
|
/*
|
|
* @brief mac_set_lp_cal_ppm_hold() set lp cal ppm hold.
|
|
* @param is_vaild: is vaild.
|
|
* @return void.
|
|
*/
|
|
void mac_set_lp_cal_ppm_hold(uint8_t is_hold);
|
|
|
|
/*
|
|
* @brief mac_cert_tt_spike_war_check() mac cert tt spike war check.
|
|
* @param void: void.
|
|
* @return void.
|
|
*/
|
|
void mac_cert_tt_spike_war_check();
|
|
|
|
/*
|
|
* @brief mac_cert_spike_pd_detect_en() mac cert get spike pd detect en.
|
|
* @param void: void.
|
|
* @return uint8_t enable or disable.
|
|
*/
|
|
uint8_t mac_cert_get_spike_pd_detect_en();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|