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

254 lines
6.6 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_PDEV_H
#define MAC_PDEV_H
#include "plc_fr.h"
#if HW_PLATFORM == HW_PLATFORM_SIMU
#include "simulator_txrx.h"
#endif
#include "mac_vdev.h"
#include "iot_mem_pool.h"
#include "plc_mac_cfg.h"
#include "mac_hwq_mgr.h"
#include "mac_rx_buf_ring.h"
#include "iot_pkt.h"
#include "mac_zc.h"
#include "mac_status.h"
#include "mac_ppm_scan.h"
#include "mac_pm.h"
#include "mac_channel.h"
#include "multi_nid_sync.h"
#include "mac_check_spur.h"
#include "mac_rf_pdev.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef uint32_t(*mac_tx_hw_comp_t)(uint32_t hwqid);
typedef uint32_t(*mac_rx_t)(void *pdev, uint32_t ring_id, uint32_t quota_ms);
typedef struct _mac_pdev {
iot_mem_pool_t vdev_pool;
uint32_t cur_vdev_num : 3,
/* this is the flag if cert mode enable */
switch_ctxt_in_mac_isr : 1,
ena_bcast_hwretry : 1,
ena_ucast_hwretry : 1,
dbg_pkt_vdev_id : 8,
/* reserved for future */
resv : 18;
mac_vdev_t *vdev[MAX_VDEV_NUM];
#if HW_PLATFORM == HW_PLATFORM_SIMU
simulator_info_t simu;
#endif
mac_queue_ctxt_t hwq_hdl;
mac_rx_ring_ctxt_t ring_hdl;
pdevid_t pdev_id;
/* mac_tx_hw_comp handler */
mac_tx_hw_comp_t tx_comp;
/* mac rx handler */
mac_rx_t rx;
/* ppm scan context */
mac_scan_ctxt_t scan;
/* channel scan context */
mac_channel_scan_ctxt_t channel_scan;
/* mac status */
mac_status_t mac_status;
uint32_t mac_isr_rx_fc_ts_ntb;
#if MAC_TIMESTAMPING
/* record rx ntb in mac rx dsr */
uint32_t mac_rx_ntb;
/* record tx hung pkt ntb when hung pkt */
uint32_t mac_tx_sw_ntb;
/* the ntb when entry mac isr */
uint32_t mac_isr_ntb;
/* the timestamp of rx mpdu end local_timestamp */
uint32_t mac_rx_timestamp;
#endif
#if DBG_RX_ABORT_REASON_4 == 1
uint32_t cont_rx_abort4_cnt;
#endif
uint8_t rx_abort_rst_cnt;
uint8_t rx_abort_spg_war_cnt;
uint16_t rsvd2;
/*power manage*/
mac_pm_t mac_pm;
#if DEBUG_CANNOT_SENDOUT_PKT
/* timer id for mac cannot send out pkt */
timer_id_t plc_tx_timer;
/* plc tx status */
uint8_t plc_tx_st : 2,
/* continuous tx timeout times */
plc_con_tx_timeout_cnt : 4,
revs1 : 2;
uint8_t plc_debug_cnt;
#endif
/*use debug dump data */
iot_pkt_t *dump_pkt;
#if DEBUG_INVAILD_ADDR
void *buf_addr;
uint32_t buf_len;
#endif
/* this means mac hw read data
* from RAM too slow
*/
uint32_t mac_underrun_cnt;
/* hw fc when just before tx */
uint32_t fc_hw[4];
#if ENABLE_CCA_ISR == 1
uint8_t cca_isr_pri; //0-3
#endif
#if ENA_SYNC_DIFF_CCO_PPM
m_ppm_cal_ctxt_t ppm_cal;
#endif
/* CCO&STA check spur support*/
mac_check_spur_ctxt_t mac_check_spur_ctxt;
#if DEBUG_HWQ_SHCED_HANG
uint32_t dbg_status;
#endif
#if PLC_SUPPORT_HW_TSFM_PA
void *hw_tsfm;
#endif
/* mac rf pdev */
mac_rf_pdev_t *mac_rf_pdev;
} mac_pdev_t;
#if DEBUG_CANNOT_SENDOUT_PKT
/* tx timer statas on init */
#define PLC_DEBUG_INIT_ST 0
/*tx timer status on print */
#define PLC_DEBUG_PRINTF_ST 1
/*tx timer status on normal calu cnt */
#define PLC_DEBUG_NORMAL_ST 2
#define PLC_DEBUG_PHY_CNT 1
#endif
/* define the max 32 ntb */
#define MAX_UINT32_NTB (0x100000000UL)
/* define the reserve ntb to max ntb 8us */
#define RESERVE_NTB (200)
/* define the max delay time 12us */
#define DELAY_MAX_NTB (300)
extern mac_pdev_t* g_mac_pdev[];
uint32_t mac_pdev_init();
/* set tx comp cb for pdev */
void mac_set_pdev_tx_comp(mac_pdev_t *pdev, \
mac_tx_hw_comp_t tx_comp_cb);
/* set rx cb for pdev */
void mac_set_pdev_rx_cb(mac_pdev_t *pdev, \
mac_rx_t rx_cb);
/*
* mac_set_pdev_cfg_internal - set a pdev's config
*
* pdev_id - which pdev to config
* cfg_struct_ptr - the pointer to the param config structure
*
* return 0 for success and non-zero for failure.
*/
uint32_t mac_set_pdev_cfg_internal(pdevid_t pdev_id, void *cfg_struct_ptr);
/*
* @brief - mac_get_pdev_cfg_internal() mac handle get pdev cfg
* @param - [pdev] pdev handler
* @param - [cfg_struct_ptr] the pointer to the param config structure
* @return - 0 for success and non-zero for failure
*/
uint32_t mac_get_pdev_cfg_internal(pdevid_t pdev_id, void *cfg_struct_ptr);
/*
* @brief - mac_pdev_send_reset_war_msg(),
* let mac or phy reset due to WAR
* @param - [pdev] pdev handler
* @param - [flag] reset flag
* @return - [none]
*/
void mac_pdev_send_reset_war_msg(mac_pdev_t *pdev, uint32_t flag);
/*
* @brief - get_pdev_ptr() get pdev
* @param - [pdev_id] pdev id
* @return - [pdev]
*/
mac_pdev_t *get_pdev_ptr(uint32_t pdev_id);
/*
* @brief - mac_tx_hang_msg() tx msg to mac task for tx hang
* @param - [timer_id] timer id
* @param - [arg]
* @return - [none]
*/
void mac_tx_hang_msg(timer_id_t timer_id, void * arg);
/*
* @brief - mac_tx_hang_handle() handle tx hang
* @return - [none]
*/
void mac_tx_hang_handle();
/*
* @brief - mac_set_bcast_hwretry_cfg() cfg bcast hwretry enable or disable
* @param - [pdev] pdev
* @param - [ena] disable/enable
* @return - [none]
*/
void mac_set_bcast_hwretry_cfg(mac_pdev_t *pdev, uint8_t ena);
/*
* @brief - mac_get_bcast_hwretry_cfg() get bcast hwretry cfg
* @param - [pdev] pdev
* @return - [cfg]
*/
uint32_t mac_get_bcast_hwretry_cfg(mac_pdev_t *pdev);
/*
* @brief - mac_rx_hang_handle() handle rx hang
* try to cold restart mac
* @return - [none]
*/
void mac_rx_hang_handle(mac_pdev_t *pdev);
#ifdef __cplusplus
}
#endif
#endif // !MAC_PDEV_H