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

293 lines
12 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_RF_TX_HW_H
#define MAC_RF_TX_HW_H
#include "os_types.h"
#include "iot_config.h"
#include "plc_utils.h"
#include "mac_rf_hwq_mgr.h"
#include "mac_rf_pdev.h"
#include "mac_msdu.h"
#ifdef __cplusplus
extern "C" {
#endif
/* rf bcsma warning depth */
#define RF_BCSMA_Q_WARNING_DEPTH (2)
#if HPLC_RF_DEV_SUPPORT
#include "rf_tx_mpdu_desc.h"
/**
*@brief mac_rf_tx_mpdu_fill_phyinfo mac rf tx mpdu fill phy information
*@param rf_mpdu_start [rf mpdu start pointer]
*@param phy_info1 [phy tx information]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_mpdu_fill_phyinfo(rf_tx_mpdu_start *rf_mpdu_start,
uint32_t phy_info1);
/**
*@brief mac_rf_tx_mpdu_fill_pb_start_info mac rf tx mpdu fill pb start
*@param pb_buf_addr [pb buf address]
*@param sof_pb_header [sof pb header]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_mpdu_fill_pb_start_info(rf_tx_pb_start *rf_pb_start,
uint32_t pb_buf_addr, uint32_t sof_pb_header);
/**
*@brief mac_rf_tx_mpdu_fill_phrinfo mac rf tx mpdu fill phy header info
*@param rf_mpdu_start [rf mpdu start pointer]
*@param proto [protocol type, see PLC_PROTO_TYPE_XXX]
*@param delimiter [delimiter type]
*@param network [network type]
*@param nid [network id]
*@param bcn_period_cnt [beacon period cnt]
*@param stei [source tei]
*@param dtei [destination tei]
*@param mcs [mcs]
*@param lid [link id]
*@param pb_sz_idx [pb size index]
*@param is_retry [is retry]
*@param is_encry [is encry]
*@param is_bcast [is broadcast]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_mpdu_fill_phrinfo(rf_tx_mpdu_start *rf_mpdu_start,
uint32_t proto, uint32_t delimiter, uint32_t network, uint32_t nid,
uint32_t bcn_period_cnt, tei_t stei, tei_t dtei, uint32_t mcs, lid_t lid,
uint32_t pb_sz_idx, uint8_t is_retry, uint8_t is_encry, uint8_t is_bcast);
/**
*@brief mac_rf_tx_mpdu_fill_macinfo mac rf tx mpdu fill mac information
*@param rf_mpdu_start [rf mpdu start pointer]
*@param next [next rf_tx_mpdu_start]
*@param pb_start [pointer to tx_pb_start]
*@param proto [protocol type, see PLC_PROTO_TYPE_XXX]
*@param end [pointer to tx_pb_end]
*@param need_ack [is need ack]
*@param retry_cnt [retry count]
*@param tx_power [tx power]
*@param retry_bit_en [retry bit enable]
*@param is_msdu [is msdu]
*@param pb_buf_reuse [is pb buf reuse]
*@param tx_desc_resue [is tx desc reuse]
*@param sw_buf_offset [sw buf offset]
*@param is_list_start [is list start]
*@param is_list_end [is list end]
*@param phr_mcs [phy frame header mcs]
*@param pts [phy timestamp]
*@param pts_off [phy timestamp offset]
*@param pld_mcs [payload mcs]
*@param blkz [pb block size]
*@param crc32_en [crc32 check enable]
*@param crc32_ofs [crc32 offset]
*@param hwq_id [swq id of mpdu queued into SW Debug]
*@param option [option]
*@param pb_num [pb numbers]
*@param tx_frame_len [tx frame length]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_mpdu_fill_macinfo(rf_tx_mpdu_start *rf_mpdu_start,
rf_tx_mpdu_start *next, rf_tx_pb_start *pb_start, rf_tx_mpdu_end *end,
uint32_t proto, uint32_t need_ack, uint32_t retry_cnt, uint32_t tx_power,
uint32_t retry_bit_en, uint8_t is_msdu, uint32_t pb_buf_reuse,
uint32_t tx_desc_resue, uint32_t sw_buf_offset, uint8_t is_list_start,
uint8_t is_list_end, uint32_t phr_mcs, uint32_t pts, uint32_t pts_off,
uint32_t pld_mcs, uint32_t blkz, uint32_t crc32_en, uint32_t crc32_ofs,
uint32_t hwq_id, uint32_t option, uint32_t pb_num, uint32_t tx_frame_len);
/**
*@brief mac_rf_tx_mpdu_form_pb mac rf tx hw mpdu form pb.
*@param pb [the point of pb]
*@param pkt_buf [the point of pkt buf]
*@param bitmap [bitmap]
*@param pb_sz [pb size]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_mpdu_form_pb(rf_tx_pb_start **pb,
iot_pkt_t *pkt_buf, uint32_t bitmap, uint32_t pb_sz);
/**
*@brief mac_rf_tx_hw_mpdu mac rf tx hw mpdu.
*@param tx_ctxt [queue ctxt]
*@param hwq_id [hwq id]
*@param mpdu [mpdu]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_hw_mpdu(mac_rf_queue_ctxt_t *tx_ctxt, uint32_t hwq_id,
rf_tx_mpdu_start *mpdu);
/**
*@brief mac_rf_tx_hw_msdu_comp mac rf tx hw msdu complete.
*@param hwq_id [hwq id]
*@param current_mpdu [current mpdu]
*@param pdev [rf pdev]
*@exception [none.]
*@return [need free msdu]
*/
mac_msdu_t *mac_rf_tx_hw_msdu_comp(uint32_t hwq_id,
rf_tx_mpdu_start * current_mpdu, mac_rf_pdev_t * pdev);
/**
*@brief mac_rf_tx_mpdu_fill_dummy mac rf tx mpdu fill dummy.
*@param rf_mpdu_dummy [point to dummy]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_mpdu_fill_dummy(rf_tx_dummy_node *rf_mpdu_dummy);
/**
*@brief mac_rf_tx_hw_mpdu_comp mac rf tx hw mpdu complete.
*@param hwq_id [hwq id]
*@param mpdu [mpdu]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_hw_mpdu_comp(uint32_t hwq_id);
/**
*@brief mac_rf_tx_flush_hwq mac rf tx flush hwq.
*@param tx_ctxt [point to tx queue ctxt]
*@param qid [qid]
*@param disable_hwq [disable hwq or not]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_flush_hwq(mac_rf_queue_ctxt_t *tx_ctxt, uint32_t qid,
uint8_t disable_hwq);
/*
* @breif mac_rf_tx_flush_bcsma_pending_queue() mac rf tx flush bcsma
* @param tx_ctxt the pointer of the rf hwq_ctxt
* @return ovid void.
*/
void mac_rf_tx_flush_bcsma_pending_queue(mac_rf_queue_ctxt_t *tx_ctxt);
/**
*@brief mac_rf_tx_flush_all_tdma_queue mac rf tx flush all tdma queue.
*@param tx_ctxt [point to tx queue ctxt]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_flush_all_tdma_queue(mac_rf_queue_ctxt_t *tx_ctxt);
/**
*@brief mac_rf_tx_flush_all_queue mac rf tx flush all hwq.
*@param tx_ctxt [point to tx queue ctxt]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_flush_all_queue(mac_rf_queue_ctxt_t *tx_ctxt);
/**
*@brief mac_rf_tx_mpdu_fill_pb_start mac rf tx mpdu fill pb start.
*@param pb [point to tx pb]
*@param buf_addr [buf addr]
*@param pb_seq [pb seq]
*@param msdu_start [is msdu start]
*@param msdu_end [is msdu end]
*@param proto [proto]
*@exception [none.]
*@return [void]
*/
void mac_rf_tx_mpdu_fill_pb_start(rf_tx_pb_start *pb, void *buf_addr,
uint32_t pb_seq, uint32_t msdu_start, uint32_t msdu_end, uint32_t proto);
/**
*@brief mac_rf_csma_bcn_flush mac rf csma beacon flush.
*@param tx_ctxt [point to tx queue ctxt]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_csma_bcn_flush(mac_rf_queue_ctxt_t *tx_ctxt);
/**
*@brief mac_rf_fill_rftest_txcali_phrinfo() - mac rf tx mpdu fill phy header info
* for rf test tx cali frame
*@param rf_mpdu_start [rf mpdu start pointer]
*@param proto [protocol type, see PLC_PROTO_TYPE_XXX]
*@param nid [network id]
*@param reg_type [tx Calibration register type,
* see RF_TEST_TX_CALI_REG_T]
*@param dev_id_magic [dev id magic]
*@param reg_magic [register combination magic]
*@return [0]
*/
void mac_rf_fill_rftest_txcali_phrinfo(rf_tx_mpdu_start *rf_mpdu_start,
uint32_t proto, uint32_t nid, RF_TEST_TX_CALI_REG_T reg_type,
uint16_t dev_id_magic, uint32_t reg_magic);
#else /* HPLC_RF_DEV_SUPPORT */
#define mac_rf_tx_flush_hwq(tx_ctxt, qid, disable_hwq) \
do { \
(void)tx_ctxt; (void)qid; (void)disable_hwq; \
} while (0)
#define mac_rf_tx_flush_bcsma_pending_queue(tx_ctxt); \
do { \
(void)tx_ctxt; \
} while (0)
#define mac_rf_tx_flush_all_tdma_queue(tx_ctxt) \
do { \
(void)tx_ctxt; \
} while (0)
#define mac_rf_tx_flush_all_queue(tx_ctxt) \
do { \
(void)tx_ctxt; \
} while (0)
#define mac_rf_tx_mpdu_fill_pb_start(pb, buf_addr, pb_seq, msdu_start, \
msdu_end) \
do { \
(void)pb; (void)buf_addr; (void)pb_seq; \
(void)msdu_start;(void)msdu_end; \
} while (0)
#define mac_rf_csma_bcn_flush(tx_ctxt) \
do { \
(void)tx_ctxt; \
} while (0)
#endif /* HPLC_RF_DEV_SUPPORT */
/**
*@brief mac_rf_tx_hw_init mac rf tx hw init.
*@param rf_pdev [rf pdev pointer]
*@exception [none.]
*@return [0]
*/
uint32_t mac_rf_tx_hw_init(mac_rf_pdev_t *rf_pdev);
#ifdef __cplusplus
}
#endif
#endif /* MAC_RF_TX_HW_H */