142 lines
4.4 KiB
C
Executable File
142 lines
4.4 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_HWQ_MGR_H
|
|
#define MAC_HWQ_MGR_H
|
|
#include "os_types.h"
|
|
#include "plc_utils.h"
|
|
#include "mac_txq_hw.h"
|
|
#include "iot_config.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define INV_MAC_HWQ_ID (uint8_t)(~0)
|
|
|
|
typedef enum _mac_queue {
|
|
MAC_QUE_BCN_A,
|
|
MAC_QUE_BCN_B,
|
|
MAC_QUE_BCN_C,
|
|
MAC_QUE_CSMA_A_0,
|
|
MAC_QUE_CSMA_A_1,
|
|
MAC_QUE_CSMA_A_2,
|
|
MAC_QUE_CSMA_A_3,
|
|
MAC_QUE_CSMA_B_0,
|
|
MAC_QUE_CSMA_B_1,
|
|
MAC_QUE_CSMA_B_2,
|
|
MAC_QUE_CSMA_B_3,
|
|
MAC_QUE_CSMA_C_0,
|
|
MAC_QUE_CSMA_C_1,
|
|
MAC_QUE_CSMA_C_2,
|
|
MAC_QUE_CSMA_C_3,
|
|
MAC_QUE_BCSMA_A,
|
|
MAC_QUE_BCSMA_B,
|
|
MAC_QUE_BCSMA_C,
|
|
MAC_QUE_TDMA_A,
|
|
MAC_QUE_TDMA_B,
|
|
MAC_QUE_TDMA_C,
|
|
MAC_QUE_NB_BCN_A,
|
|
MAC_QUE_NB_BCN_B,
|
|
MAC_QUE_NB_BCN_C,
|
|
MAX_MAC_QUE_NUM
|
|
} mac_queue_t;
|
|
|
|
typedef struct _mac_queue_ctxt {
|
|
/* the last available hwq id*/
|
|
uint8_t last_hwq_id;
|
|
/* store the hwq id for each swq type id */
|
|
uint8_t hwq_map[MAX_MAC_QUE_NUM];
|
|
/* store the last desc for each hwq */
|
|
void *last_desc[MAX_MAC_TXQ_NUM];
|
|
/* store the current sw handle ptr for each hwq */
|
|
void *cur_hdl_desc[MAX_MAC_TXQ_NUM];
|
|
/* cur msdu ctxt for each hwq */
|
|
void *cur_msdu_ptr[MAX_MAC_TXQ_NUM];
|
|
/*hwq depth*/
|
|
uint16_t q_depth[MAX_MAC_TXQ_NUM];
|
|
/* hwq block */
|
|
uint8_t is_block_all_tx;
|
|
} mac_queue_ctxt_t;
|
|
|
|
/* init the hwq ctxt */
|
|
void mac_q_init(mac_queue_ctxt_t *queue);
|
|
|
|
/* get the real hwq mapping id
|
|
* @queue - hwq handler
|
|
* @mac_que - sw queue that designated
|
|
* return - the real hwq id that mapping to MAC HW if allocated
|
|
* INV_MAC_HWQ_ID if not allocated
|
|
*/
|
|
uint8_t mac_q_get_hwqid(mac_queue_ctxt_t *queue, mac_queue_t qtype);
|
|
|
|
uint8_t mac_q_alloc_hwq(mac_queue_ctxt_t *queue, mac_queue_t qtype);
|
|
|
|
/* get beacon region type from lid */
|
|
uint32_t mac_get_bcn_region_type(lid_t lid);
|
|
|
|
/* check if has msdu for current sending */
|
|
uint8_t mac_token_check(uint32_t bcn_region_type, lid_t lid, uint8_t is_rf);
|
|
/* TX done,return token */
|
|
void mac_token_free(uint32_t bcn_region_type, lid_t lid, uint8_t is_rf);
|
|
/* TX,take token */
|
|
void mac_token_alloc(uint32_t bcn_region_type, lid_t lid, uint8_t is_rf);
|
|
|
|
/* get the swq id from region type, phase and lid
|
|
* return MAX_MAC_QUE_NUM if error
|
|
*/
|
|
mac_queue_t mac_q_get_swq_type(uint32_t bcn_region_type, \
|
|
uint32_t phase, lid_t lid);
|
|
|
|
/* get the swqid from phase and lid info */
|
|
uint32_t mac_q_get_swqid_from_phase_lid(mac_queue_ctxt_t *queue, \
|
|
uint32_t phase, lid_t lid);
|
|
|
|
/* get the hwqid from swq id info */
|
|
uint32_t mac_q_create_hwqid_from_swqid(mac_queue_ctxt_t *queue, \
|
|
mac_queue_t swq_id);
|
|
|
|
/*
|
|
* @breif mac_block_all_tx_ena() set hw block
|
|
* @param tx_ctxt the pointer of the hwq_ctxt
|
|
* @param uint32_t ena enable/disable]
|
|
* @return uint32_t ERR_OK
|
|
*/
|
|
uint32_t mac_block_all_tx_ena(mac_queue_ctxt_t *tx_ctxt, uint32_t ena);
|
|
|
|
/*
|
|
* @breif mac_is_block_all_tx() - get is block tx status
|
|
* @param pdev the pointer of the hwq_ctxt
|
|
* @return uint32_t 0: false; other: true;
|
|
*/
|
|
uint32_t mac_is_block_all_tx(mac_queue_ctxt_t *tx_ctxt);
|
|
|
|
/**
|
|
*@brief mac_tx_flush_hwq mac tx flush hwq.
|
|
*
|
|
* @param tx_ctxt the pointer of the hwq_ctxt
|
|
*@param qid hwqid.
|
|
*@param disable_hwq need disable hwq.
|
|
*
|
|
*@return success;
|
|
*/
|
|
uint32_t mac_tx_flush_hwq(mac_queue_ctxt_t *tx_ctxt, uint32_t qid,
|
|
uint8_t disable_hwq);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif //MAC_HWQ_MGR_H
|