/*******************************************************************************
 * (c) Copyright 2015 Microsemi Corporation.  All rights reserved.
 *
 *
 *
 * SVN $Revision: $
 * SVN $Date: $
 */

#ifndef __MR_API_PRIVATE_TYPES_H__
#define __MR_API_PRIVATE_TYPES_H__

#include	"egl_types.h"

typedef uint8_t		lcNum_t;
typedef int16_t		lMepNum_t;
typedef int16_t		rMepNum_t;
typedef	uint16_t	rMepTblIdx_t;
typedef	uint16_t	rxLMepTblIdx_t;

typedef struct mdFullEntry_s mdAPIEntry_t;

typedef struct maFullEntry_s maAPIEntry_t;

typedef struct lMepFullEntry_s lMepAPIEntry_t;

typedef struct rMepFullEntry_s rMepAPIEntry_t;

typedef uint32_t		mdHandle_t;
typedef uint32_t		maHandle_t;
typedef uint32_t		lMepHandle_t;
typedef uint32_t		rMepHandle_t;

typedef	uint8_t		mdNumOld_t;
typedef	uint8_t		maNumOld_t;

//========================================================================
//
typedef struct mdHandleRec_s mdHandleRec_t;

struct mdHandleRec_s {
	mdHandle_t		handle;
	mdHandleRec_t	*next;
	mdHandleRec_t	*prev;
};

typedef struct maHandleRec_s maHandleRec_t;

struct maHandleRec_s {
	maHandle_t		handle;
	maHandleRec_t	*next;
	maHandleRec_t	*prev;
};

typedef struct lMepHandleRec_s lMepHandleRec_t;

struct lMepHandleRec_s {
	lMepHandle_t		handle;
	lMepHandleRec_t		*next;
	lMepHandleRec_t		*prev;
};

typedef struct rMepHandleRec_s rMepHandleRec_t;

struct rMepHandleRec_s {
	rMepHandle_t		handle;
	rMepHandleRec_t		*next;
	rMepHandleRec_t		*prev;
};

// Mask values used by the svcCfg parameter in service types
#define	MR_SVC_CFG_ORIG		0x01
#define	MR_SVC_CFG_RESP		0x02

//========================================================================
typedef struct lmmSvc_s lmmSvc_t;

struct lmmSvc_s {
	pmNum_t			pmNum;
	lcNum_t			lcNum;
	uint8_t			svcCfg;
	uint8_t			prio;
	rMepNum_t		rMepNum;
};

//========================================================================
typedef struct dmmSvc_s dmmSvc_t;

struct dmmSvc_s {
	pmNum_t		pmNum;
	uint8_t		prio;
	uint8_t		svcCfg;
};
//========================================================================
typedef struct idmSvc_s idmSvc_t;

struct idmSvc_s {
	pmNum_t		pmNum;
	uint8_t		prioO;
	uint8_t		prioR;
	uint8_t		svcCfg;
};
//========================================================================
typedef struct slmSvc_s slmSvc_t;

struct slmSvc_s {
	pmNum_t		pmNumO;
	lcNum_t		lcNumO;
	lcNum_t		lcNumR;
	uint8_t		svcCfg;
};
//========================================================================
typedef struct rMepServices_s rMepServices_t;

struct rMepServices_s {
	slmSvc_t		slmSvc[8];
	dmmSvc_t		dmmSvc[MR_MAX_DMM_PER_RMEP];
	idmSvc_t		idmSvc;
};
//========================================================================
typedef struct lMepServices_s lMepServices_t;

struct lMepServices_s {
	lmmSvc_t		lmmSvc;
};
//========================================================================
// CfmMdTable


typedef struct mdListOld_s mdListOld_t;
struct mdListOld_s {
		lMepNum_t		maidIdx;
		uint8_t			mdLevel;
};
typedef struct maListOld_s maList_t;
struct maListOld_s {
		lMepNum_t		maidIdx;
		mdNumOld_t			parentMd;
};

typedef struct lMepListOld_s lMepList_t;
struct lMepListOld_s {
		maNumOld_t			parentMa;
		enDis_t			enableCCMAlarms;
		uint16_t			vLan;
		lMepServices_t	*_services;
};

typedef struct rMepListOld_s rMepList_t;
struct rMepListOld_s {
		enDis_t			ccmEn;
		rMepServices_t	*_services;
};

//========================================================================

struct mdFullEntry_s {
	mdNameFormatLen_t	mdName;							// The MD Name
	uint8_t				mdLevel;						// The MD Level
	maAPIEntry_t		*maLinkListPtr;					// Pointer to the start of the associated MA linked list
	uint32_t				_numberOfMAs;					// Integer giving the number of entries in the attached MA linked list
	mdAPIEntry_t		*_nextEntry;					// A pointer to the next entry in this MA Linked List
	mdAPIEntry_t		*_prevEntry;					// A pointer to the previous entry in this MA Linked List
};


//========================================================================
// MD List
/*
typedef struct mdList_s mdListOld_t;

struct mdList_s {
	mdAPIEntry_t			*mdListStart;				// A pointer to the start of the MD list
	uint32_t					_numberOfMDs;				// Integer giving the number of entries in the MD list
};
*/

//========================================================================
// MA Types

struct maFullEntry_s {
	maNameFormatLen_t		maName;						// The MD Name/type/length
	ccmIntervalOld_t			ccmInterval;				// The enumerated value for the CCM Interval
	mdAPIEntry_t			*_mdEntryPtr;				// A pointer back to the associated MD entry
	lMepAPIEntry_t			*_lMepList;					// A pointer to a linked list of associated Local MEPs
	uint32_t					_numberOfLMeps;				// The number of local meps in the localMepList
	maAPIEntry_t			*_nextEntry;				// A pointer to the next entry in this MA Linked List
	maAPIEntry_t			*_prevEntry;				// A pointer to the previous entry in this MA Linked List
};

//========================================================================
// Local MEP Types

struct lMepFullEntry_s {
	mepId_t					mepID;						// The MEP ID of this MEP
	uint32_t					port;						// The Associated Port
	mepDir_t				direction;					// MEP direction.
	vidEntry_t				primaryVid;					// Value of Primary VID
	mepType_t				type;						// MEP Type, MEP = 0, MIP = 1
	tag_t					sTag;						// holds S-Tag info.
	tag_t					cTag;						// holds C-Tag info.
	enDis_t					txAIS;						// if enabled then AIS packets will be transmitted
	enDis_t					txLCK;						// if enabled then LCK packets will be transmitted
	enDis_t					enableCCMAlarms;			// if enabled then CCM Alarms are disabled
	uint16_t					_lMepNum;
	boolean_t				_lMepNumValid;
	rMepAPIEntry_t			*_rMepList;					// Pointer to a list of remote mep DB entries
	uint32_t					_numberOfRMeps;				// Integer indicating the number of remote meps in _remoteMepDBList
	maAPIEntry_t			*_maEntryPtr;				// Pointer to associated MA
	lMepAPIEntry_t			*_nextEntry;				// Pointer to next entry in Local MEP Linked list
	lMepAPIEntry_t			*_prevEntry;				// Pointer to previous entry in Local MEP Linked list
	uint8_t					proHdr[16];
	uint8_t					proHdrLen;
	lMepServices_t			*_services;
};

//========================================================================


struct rMepFullEntry_s {
	mepId_t					mepID;						// The MEP ID of the (remote) MEP associated with this DB entry
	macAddress_t			macAddress;					// The MAC Address of the associated remote MEP
	enDis_t					ccmEn;
	uint16_t					_rMepNum;
	uint8_t					_rMepNumValid;
	uint16_t					_rxLMepTblIdx;				// This is assigned when adding lMep 2 HW and needed when deleting lMep
	lMepAPIEntry_t			*_lMepEntryPtr;
	rMepAPIEntry_t			*_nextEntry;				// Pointer to next entry in Remote MEP Linked list
	rMepAPIEntry_t			*_prevEntry;				// Pointer to previous entry in Remote MEP Linked list
	rMepServices_t			*_services;
};


//========================================================================
// register type - used for saving and restoring the HW configuration
typedef struct mip_register_s mip_register_t;

struct mip_register_s {
	uint32_t			regAddr;							// The register Address
	uint32_t			value;								// The register value
};

//========================================================================

typedef struct pmSvcVlanCount_s pmSvcVlanCount_t;

struct	pmSvcVlanCount_s {
	uint16_t	vlan;
	uint8_t	count;
};
//========================================================================

typedef uint8_t simpleMaid_t[48];

#endif
