184 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			184 lines
		
	
	
		
			6.2 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 CVG_MSG_H
 | 
						|
#define CVG_MSG_H
 | 
						|
 | 
						|
/* os shim includes */
 | 
						|
#include "os_types.h"
 | 
						|
 | 
						|
/* common includes */
 | 
						|
#include "iot_task.h"
 | 
						|
#include "iot_config.h"
 | 
						|
 | 
						|
/* cvg internal includes */
 | 
						|
#include "cvg.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* define the cvg message queue count and priorities, the higer the priority
 | 
						|
 * the lower the queue number.
 | 
						|
 */
 | 
						|
#define CVG_MSG_QUEUE_HP            0
 | 
						|
#define CVG_MSG_QUEUE_LP            1
 | 
						|
#define CVG_MSG_QUEUE_MAX_PRIO      2
 | 
						|
 | 
						|
#if (PLC_SUPPORT_CCO_ROLE)
 | 
						|
/* define CVG layer message pool size */
 | 
						|
#define CVG_MSG_POOL_SIZE           255
 | 
						|
#else
 | 
						|
/* define CVG layer message pool size */
 | 
						|
#define CVG_MSG_POOL_SIZE           (128 + 64)
 | 
						|
#endif
 | 
						|
 | 
						|
/* message type definition */
 | 
						|
#define CVG_MSG_TYPE_OTHERS         1   /* messages from vairous sources */
 | 
						|
#define CVG_MSG_TYPE_APP            2   /* messages from application layer */
 | 
						|
#define CVG_MSG_TYPE_MAC            3   /* messages from mac layer */
 | 
						|
#define CVG_MSG_TYPE_TIMER          4   /* messages from cvg internal timer */
 | 
						|
 | 
						|
/* message id definitions for app */
 | 
						|
#define CVG_MSG_ID_APP_CMD          0   /* app message */
 | 
						|
 | 
						|
/* messages id definitions for others type */
 | 
						|
/* start vdev reqeust */
 | 
						|
#define CVG_MSG_ID_OTHERS_START_VDEV    1
 | 
						|
/* new beacon period notification */
 | 
						|
#define CVG_NSG_ID_OTHERS_NEW_BP        2
 | 
						|
/* pm power manager notification */
 | 
						|
#define CVG_MSG_ID_OTHERS_PM_MSG        3
 | 
						|
/* white list or black list changed notification */
 | 
						|
#define CVG_MSG_ID_OTHERS_WBL_CHG_MSG   4
 | 
						|
/* async crypto done notification */
 | 
						|
#define CVG_MSG_ID_OTHERS_CRYPTO_DONE   5
 | 
						|
 | 
						|
/* message id definitions for timer type */
 | 
						|
/* cco start listen timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_SL           1
 | 
						|
/* discover node mme send timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_DIS_NODE     2
 | 
						|
/* route period timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_ROUTE        3
 | 
						|
/* sta joining network timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_JOIN         4
 | 
						|
/* sta leaving network timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_LEAVE        5
 | 
						|
/* sta clear blacklist timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_CLEAR_BLIST  6
 | 
						|
/* sta test mode timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_TEST         7
 | 
						|
/* cco start assoc request gather timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_ASSOC_GATHER 8
 | 
						|
/* sta  frequency change timer timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_FB_CHG       9
 | 
						|
/* partial route period timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_RP_PARTIAL   10
 | 
						|
/* sta watch dog timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_WDG          11
 | 
						|
/* sta monitor network timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_MONITOR      12
 | 
						|
/* sta monitor network log timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_MONITOR_LOG  13
 | 
						|
/* cco zero-cross NTB area notification timer timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_ZC_NOTIFY    14
 | 
						|
/* timeout for controller protocol */
 | 
						|
#define CVG_MSG_TYPE_TIMER_CTRL_PROTO   15
 | 
						|
/* timeout for conn less */
 | 
						|
#define CVG_MSG_TYPE_TIMER_CONN_LESS    16
 | 
						|
/* sta rf channel change timer timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_RF_CHG       17
 | 
						|
/* timeout for rf channel conflict */
 | 
						|
#define CVG_MSG_TYPE_TIMER_RF_SL        18
 | 
						|
/* cco start rf assoc request gather timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_RF_ASSOC_GATHER 19
 | 
						|
/* rf discover node mme send timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_RF_DIS_NODE  20
 | 
						|
/* timeout for security authorization */
 | 
						|
#define CVG_MSG_TYPE_TIMER_AUTH         21
 | 
						|
/* timeout for rf scan timeout */
 | 
						|
#define CVG_MSG_TYPE_TIMER_RF_SCAN      22
 | 
						|
 | 
						|
/* messages id definitions for MAC type */
 | 
						|
#define CVG_MSG_ID_MAC_BEACON_RX        1   /* beacon rx */
 | 
						|
#define CVG_MSG_ID_MAC_SOF_RX           2   /* sof frame rx */
 | 
						|
#define CVG_MSG_ID_MAC_CCO_SNR_RX       3   /* cco snr rx */
 | 
						|
#define CVG_MSG_ID_MAC_BP_END_ALERT     4   /* beacon period end alert */
 | 
						|
#define CVG_MSG_ID_MAC_NID_RPT          5   /* watch nid list report */
 | 
						|
#define CVG_MSG_ID_MAC_ZC_NTB_RPT       6   /* zero cross ntb report */
 | 
						|
#define CVG_MSG_ID_MAC_ZC_STATUS_RPT    7   /* zero cross status report */
 | 
						|
 | 
						|
/* cvg message */
 | 
						|
typedef struct _cvg_msg {
 | 
						|
    /* cvg task message */
 | 
						|
    iot_task_msg_t  task_msg;
 | 
						|
    /* message data */
 | 
						|
    uint32_t        data1;
 | 
						|
    void            *data2;
 | 
						|
} cvg_msg_t;
 | 
						|
 | 
						|
/*
 | 
						|
 * cvg_alloc_msg() - allocate one message from global msg pool
 | 
						|
 *
 | 
						|
 * return:
 | 
						|
 *      NULL      -- for failure case
 | 
						|
 *      othersie  -- pointer of allocated message
 | 
						|
 */
 | 
						|
#define cvg_alloc_msg() ((cvg_msg_t *)iot_task_alloc_msg(p_cvg_glb->task_h))
 | 
						|
 | 
						|
/*
 | 
						|
 * cvg_alloc_msg_with_reserved() - allocate one message from global msg pool
 | 
						|
 *                                 with reserved free messages in the pool.
 | 
						|
 *
 | 
						|
 * return:
 | 
						|
 *      NULL      -- for failure case
 | 
						|
 *      othersie  -- pointer of allocated message
 | 
						|
 */
 | 
						|
#define cvg_alloc_msg_with_reserved(reserved) \
 | 
						|
    ((cvg_msg_t *)iot_task_alloc_msg_with_reserved((p_cvg_glb->task_h), \
 | 
						|
    reserved))
 | 
						|
 | 
						|
/*
 | 
						|
 * cvg_free_msg() - free one message back to global msg pool
 | 
						|
 * @msg:    pointer of msg to be freed
 | 
						|
 */
 | 
						|
#define cvg_free_msg(msg) \
 | 
						|
    (iot_task_free_msg(p_cvg_glb->task_h, (iot_task_msg_t *)msg))
 | 
						|
 | 
						|
/*
 | 
						|
 * cvg_queue_msg() - queue one message into msg queues based on the priority
 | 
						|
 * @msg:    pointer of msg to be queued
 | 
						|
 * @prio:   the priority of the message
 | 
						|
 */
 | 
						|
#define cvg_queue_msg(msg, prio) \
 | 
						|
    (iot_task_queue_msg(p_cvg_glb->task_h, (iot_task_msg_t *)msg, prio))
 | 
						|
 | 
						|
 | 
						|
/*
 | 
						|
 * cvg_clean_msg() - clean up specified messages
 | 
						|
 * @type:   type of the messages to be canceled
 | 
						|
 * @id:     id of messages to be canceled
 | 
						|
 */
 | 
						|
#define cvg_clean_msg(type, id) \
 | 
						|
    (iot_task_clean_msg(p_cvg_glb->task_h, type, id))
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* CVG_MSG_H */
 |