213 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			213 lines
		
	
	
		
			7.8 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_MSG_H
 | 
						|
#define MAC_MSG_H
 | 
						|
 | 
						|
/* os shim includes */
 | 
						|
#include "os_types.h"
 | 
						|
#include "os_event.h"
 | 
						|
 | 
						|
/* common includes */
 | 
						|
#include "iot_queue.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* message type definition */
 | 
						|
#define MAC_MSG_TYPE_CVG            1    /* messages from cvg layer */
 | 
						|
#define MAC_MSG_TYPE_DSR            2    /* messages from dsr */
 | 
						|
#define MAC_MSG_TYPE_TIMER          3    /* messages from mac internal timer */
 | 
						|
#define MAC_MSG_TYPE_SCH            4    /* messages from sw sched */
 | 
						|
#define MAC_MSG_TYPE_MAC            5    /* messages from mac layer */
 | 
						|
#define MAC_MSG_TYPE_PM             6    /* messages from power managerment sources*/
 | 
						|
#define MAC_MSG_TYPE_PHY            7    /* messages from phy layer */
 | 
						|
#define MAC_MSG_TYPE_CLI            8    /* messages from cli */
 | 
						|
 | 
						|
/* message id definitions for cvg type */
 | 
						|
#define MAC_MSG_ID_CVG_START_BC         1    /* start beacon */
 | 
						|
#define MAC_MSG_ID_CVG_STOP_BC          2    /* stop beacon */
 | 
						|
#define MAC_MSG_ID_CVG_UPDATE_BC        3    /* update tx beacon template */
 | 
						|
#define MAC_MSG_ID_CVG_CREATE_VDEV      4    /* create vdev */
 | 
						|
#define MAC_MSG_ID_CVG_START_VDEV       5    /* start vdev */
 | 
						|
#define MAC_MSG_ID_CVG_SET_VDEV_CFG     6    /* set vdev config */
 | 
						|
#define MAC_MSG_ID_CVG_STOP_VDEV        7    /* stop vdev */
 | 
						|
#define MAC_MSG_ID_CVG_MSDU_SEND        8    /* send msdu */
 | 
						|
#define MAC_MSG_ID_CVG_CERT_MODE_SEL    9    /* cert test mode sel */
 | 
						|
#define MAC_MSG_ID_CVG_CERT_BAND        10   /* cert test band sel */
 | 
						|
#define MAC_MSG_ID_CVG_CERT_TONEMASK    11   /* cert test tonemask sel */
 | 
						|
#define MAC_MSG_ID_CVG_SET_PDEV_CFG     12   /* set pdev config */
 | 
						|
#define MAC_MSG_ID_CVG_START_ZC_NTB     13   /* start zero-cross ntb collect */
 | 
						|
#define MAC_MSG_ID_CVG_EXT_FRAME_SEND   14   /* cvg send ext frame */
 | 
						|
#define MAC_MSG_ID_CVG_GET_PDEV_CFG     15   /* set pdev config */
 | 
						|
#define MAC_MSG_ID_CVG_HW_TSFM_SEND     16   /* send hw tsfm data */
 | 
						|
#define MAC_MSG_ID_CVG_CERT_HPLC2RF     17   /* cert test hplc2rf param cfg */
 | 
						|
#define MAC_MSG_ID_CVG_CERT_SEC_MODE    18   /* cert test security mode cfg */
 | 
						|
#define MAC_MSG_ID_CVG_CERT_RF_CFG      19   /* cert test rf config */
 | 
						|
#define MAC_MSG_ID_CVG_GET_VDEV_CFG     20   /* get vdev config */
 | 
						|
 | 
						|
/* message id definitions for dsr type */
 | 
						|
#define MAC_MSG_ID_DSR_RX_TO_MSG        1   /* make dsr to event for balance tx */
 | 
						|
 | 
						|
/* message id definition from sw sched */
 | 
						|
#define MAC_MSG_ID_SCH_TX               1   /* start send a frame list */
 | 
						|
 | 
						|
/* message id definition from other */
 | 
						|
#define MAC_MSG_ID_PM_OFF               1   /* prower off msg */
 | 
						|
#define MAC_MSG_ID_PWR_CHANGE           2   /* change power for power off */
 | 
						|
 | 
						|
/* message id definition for mac type */
 | 
						|
#define MAC_MSG_ID_MAC_WARM_RESET_WAR   1   /* WAR reset mac or phy */
 | 
						|
#define MAC_MSG_ID_MAC_DEBUG_TX_HANG    2   /* mac debug tx hang */
 | 
						|
#define MAC_MSG_ID_MAC_ZC_SET_FUNC_CMD  3   /* set mac zc function command */
 | 
						|
 | 
						|
/* message id definition from timer */
 | 
						|
#define MAC_MSG_ID_SCHED_TX                  1   /* start nncco frame tx */
 | 
						|
#define MAC_MSG_ID_ZC_TRAIN_HW_TIMER         2   /* mac zc training timeout */
 | 
						|
#define MAC_MSG_ID_SYSTEM_SLEEP              3   /* sleep or wake up system */
 | 
						|
#define MAC_MSG_ID_CHANNEL_SCAN_TIMER        4   /* mac scan timer msg */
 | 
						|
#define MAC_MSG_ID_CCO_CHECK_SPUR_TIMER      5   /* mac check spur timer msg */
 | 
						|
#define MAC_MSG_ID_STA_CHECK_SPUR_TIMER      6   /* mac check spur timer msg */
 | 
						|
#define MAC_MSG_ID_DEL_STREAM_TIMER          7   /* delete timeout stream */
 | 
						|
#define MAC_MSG_ID_STA_PERIOD_CHECK_SPUR     8   /* period all check spur msg */
 | 
						|
#define MAC_MSG_ID_RF_SCAN_TIMER             9   /* mac rf scan timer msg */
 | 
						|
#define MAC_MSG_ID_PPM_RECORD_TIMER          10  /* ppm record timer msg */
 | 
						|
#define MAC_MSG_ID_MAC_CERT_WAR_TIMER        11  /* WAR for jinlin cert hplc tt test */
 | 
						|
 | 
						|
/* message id definitions for phy type */
 | 
						|
#define MAC_MSG_ID_CHANNEL_TEST_STOP      1   /* test done, reinit phy and mac */
 | 
						|
/* channel estimated */
 | 
						|
#define MAC_MSG_ID_CHANNEL_ESTIMATED      2
 | 
						|
 | 
						|
/* message id definitions for cli type */
 | 
						|
#define MAC_MSG_ID_CHANNEL_DUMP_TEST      1   /* channel dump test start */
 | 
						|
 | 
						|
/* message id definitions for clean all message */
 | 
						|
#define MAC_MSG_ID_ALL                    0xFFFF
 | 
						|
 | 
						|
 | 
						|
/* mac message */
 | 
						|
typedef struct _mac_msg {
 | 
						|
    /* link of the message queue */
 | 
						|
    iot_msg_entry_t link;
 | 
						|
    /* message type */
 | 
						|
    uint8_t         type;
 | 
						|
    /* flag to mark if message is sync message */
 | 
						|
    uint8_t         sync;
 | 
						|
    /* message id */
 | 
						|
    uint16_t        id;
 | 
						|
    /* message data */
 | 
						|
    uint32_t        data1;
 | 
						|
    void            *data2;
 | 
						|
    void            *data3;
 | 
						|
} mac_msg_t;
 | 
						|
 | 
						|
/* mac sync message */
 | 
						|
typedef struct _mac_msg_sync {
 | 
						|
    /* message, must be the first item of the data structure */
 | 
						|
    mac_msg_t       msg;
 | 
						|
    /* event for sync purpose */
 | 
						|
    os_event_h      event;
 | 
						|
} mac_msg_sync_t;
 | 
						|
 | 
						|
/* mac message queue */
 | 
						|
typedef struct _mac_msg_queue {
 | 
						|
    /* queue to link the message */
 | 
						|
    iot_msg_queue_t q;
 | 
						|
    /* current quota of the queue */
 | 
						|
    uint8_t         curr_quota;
 | 
						|
    /* assgined quota of the queue */
 | 
						|
    uint8_t         quota;
 | 
						|
    /* flag to mark if quota feature enabled for this queue */
 | 
						|
    uint8_t         quota_en;
 | 
						|
    /* reserved for future */
 | 
						|
    uint8_t        reserved;
 | 
						|
} mac_msg_queue_t;
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_init_msg_pool() - init mac layer msg pool
 | 
						|
 *
 | 
						|
 * return:
 | 
						|
 *      0         -- for success case
 | 
						|
 *      othersie  -- error code
 | 
						|
 */
 | 
						|
uint32_t mac_init_msg_pool();
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_deinit_msg_pool() - deinit mac layer msg pool
 | 
						|
 */
 | 
						|
void mac_deinit_msg_pool();
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_alloc_msg() - allocate one message from mac msg pool
 | 
						|
 *
 | 
						|
 * return:
 | 
						|
 *      NULL      -- for failure case
 | 
						|
 *      othersie  -- pointer of allocated message
 | 
						|
 */
 | 
						|
mac_msg_t *mac_alloc_msg();
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_free_msg() - free one message back to mac msg pool
 | 
						|
 * @msg:    pointer of msg to be freed
 | 
						|
 */
 | 
						|
void mac_free_msg(mac_msg_t *msg);
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_clean_msg() - clean message from mac task message queue
 | 
						|
 * @msg_type :       message type to be cleaned
 | 
						|
 * @msg_id :         message id to be cleaned. if msg_id is MAC_MSG_ID_ALL, all
 | 
						|
 *                   the messages whose type is msg_type will be cleaned
 | 
						|
 * @return :         none
 | 
						|
 */
 | 
						|
void mac_clean_msg(uint8_t msg_type, uint16_t msg_id);
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_queue_msg() - queue one message into mac msg queues
 | 
						|
 * @msg:    pointer of msg to be queued
 | 
						|
 * #prio:   the priority of the message
 | 
						|
 */
 | 
						|
void mac_queue_msg(mac_msg_t *msg, uint8_t prio);
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_alloc_msg_sync() - allocate one sync message from sync mac msg pool
 | 
						|
 *
 | 
						|
 * return:
 | 
						|
 *      NULL      -- for failure case
 | 
						|
 *      othersie  -- pointer of allocated message
 | 
						|
 */
 | 
						|
mac_msg_sync_t *mac_alloc_msg_sync();
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_free_msg_sync() - free one sync message back to mac sync msg pool
 | 
						|
 * @msg:    pointer of msg to be freed
 | 
						|
 */
 | 
						|
void mac_free_msg_sync(mac_msg_sync_t *msg);
 | 
						|
 | 
						|
/*
 | 
						|
 * mac_queue_msg_sync() - queue one sync message into mac msg queues
 | 
						|
 * @msg:    pointer of sync msg to be queued
 | 
						|
 * #prio:   the priority of the sync message
 | 
						|
 */
 | 
						|
void mac_queue_msg_sync(mac_msg_sync_t *msg, uint8_t prio);
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* MAC_MSG_H */
 |