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

#ifndef __TABLE_TYPES_H__
#define __TABLE_TYPES_H__

#include <api_oam_sdk/common/types/inc/mr_api_types.h>
#include <api_oam_sdk/maintenance_association/src/ma_types.h>
#include <api_oam_sdk/maintenance_domain/src/md_types.h>
#include <api_oam_sdk/service_evc/src/svc_evc_types.h>

typedef struct rMepTblEntry_s rMepTblEntry_t;
struct rMepTblEntry_s {
	uint8_t	endBitU;
	uint8_t	jumpU;
	uint16_t	nextPtrU;
	uint8_t	endBitL;
	uint8_t	jumpL;
	uint16_t	nextPtrL;
};


typedef struct rMepDbTblEntry_s rMepDbTblEntry_t;
struct rMepDbTblEntry_s {
	uint16_t				remoteMepID;
	uint16_t				rMepIdx;
	uint32_t				seqNum;
	uint8_t				SA[6];
	uint8_t				tlv[56];
#if 0 // REMOVED FOR V2
	lineCountEntry_t 	lc[8];
#endif
};

typedef struct lMepTblEntry_s lMepTblEntry_t;
struct lMepTblEntry_s {
	uint16_t			lMepID;
	ccmInterval_t		interval;
	mdNum_t			mdNum;
	maNum_t			maNum;
	simpleMaid_t	maid;
};

typedef struct dirLvlTblEntry_s dirLvlTblEntry_t;
struct dirLvlTblEntry_s {
	uint8_t	downMask;
	uint8_t	upMask;
	uint16_t	rxLMepListIdx;
	uint8_t	swDownMask;
	uint8_t	swUpMask;
};

typedef enum mp_Enum {
	mp_tableInUse	= 0,
	mp_isAMep		= 1,
	mp_isAMip		= 2,
	mp_tableEmpty	= 3
}mpType_t;

typedef struct rxLMepNumRamEntry_s rxLMepNumRamEntry_t;
struct rxLMepNumRamEntry_s {
	uint16_t	rxLMepNum;
	pmNum_t		idmPmNum;
	uint8_t		idmPrio;
	uint8_t		levelMask;
	mpType_t	mpType;
};


typedef struct txLMepNumRamEntry_s txLMepNumRamEntry_t;
struct txLMepNumRamEntry_s {
	valid_t ccmValid;
	ccmIntervalOld_t ccmInt;
	enDis_t ccmEn;
	enDis_t aisEn;
	enDis_t lckEn;
	iFace_t	iFace;
};


typedef struct vlanPortTblEntry_s vlanTblEntry_t;
struct vlanPortTblEntry_s {
	uint16_t	evcIdx;
	uint16_t	cfmIdx;
	bool		vlanFilt;					// if true all packets on the VLAN are prevented from being forwarded - This does not affect CFM destined for this device.
	valid_t		cfmValid;					// Set to valid if there is any MIP/MEP on this vlan on this port.
	bool		vLanFiltRestore;			// Used by SW only to record if this vlan is filtered at the Interface. Used to restore vlanFilt.
};

typedef struct rMepSMEntry_s rMepSMEntry_t;
struct rMepSMEntry_s {
	rMepSMStates_t	state;
	rdiVal_t		rdi;
	uint32_t		timer;
	uint8_t			goodCount;
	enDis_t			enable;
};

typedef struct xConnSMEntry_s xConnSMEntry_t;
struct xConnSMEntry_s {
	smStates_t	state;
	uint32_t	timer;
	enDis_t		enable;
};

typedef struct rMepErrSMEntry_s rMepErrSMEntry_t;
struct rMepErrSMEntry_s {
	smStates_t	state;
	uint32_t	timer;
	enDis_t		enable;
};

typedef struct lineStatsEntry_s lineStatsEntry_t;
struct lineStatsEntry_s {
	uint32_t	neTx;
	uint32_t	neRx;
};

typedef struct lbmStoreEntry_s lbmStoreEntry_t;
struct lbmStoreEntry_s {
	uint32_t	counter;
	uint16_t	lMepNum;
};

typedef struct pmStatsRamEntry_s pmStatsRamEntry_t;
struct pmStatsRamEntry_s {
	svcEn_t		enFL;			// offset 0
	uint8_t		fltDiv128;		// offset 0
	uint8_t		firstLmr;		// offset 0
	uint32_t	fLThres;		// offset 0
	uint8_t		dtlPm;			// offset 0
	uint8_t		sESFlg;			// offset 0
	uint8_t		eSFlg;			// offset 0
	uint32_t	lastNeTx;		// offset 1
	uint32_t	lastFeRx;		// offset 2
	uint32_t	neTxCntr;		// offset 3
	uint32_t	feRxCntr;		// offset 4
	uint32_t	lastFeTx;		// offset 5
	uint32_t	lastNeRx;		// offset 6
	uint32_t	feTxCntr;		// offset 7
	uint32_t	neRxCntr;		// offset 8

	uint32_t	SESCntr;		// offset 12
	uint32_t	ESCntr;			// offset 13

	uint16_t	lMepNum;		// offset 15
	uint16_t	rMepNum;		// offset 15
	uint8_t		enAlm;			// offset 15

	uint32_t	lastJitter;		// offset 16
	uint32_t	lastDelay;		// offset 17
	uint32_t	fDPktCntr;		// offset 18
	uint32_t	sumLatLow;		// offset 19
	uint32_t	sumLatUpp;		// offset 20
	uint32_t	sumJittLow;		// offset 21
	uint32_t	sumJittUpp;		// offset 22
	uint8_t		firstRx;		// offset 23
	svcEn_t		enFD;			// offset 23
	uint32_t	fDThres;		// offset 23
	uint8_t		fD1SErrCntr;	// offset 23
	uint32_t	fDErrCntr;		// offset 24
	uint32_t	fDVThres;		// offset 25
	uint8_t		fDV1SErrCntr;	// offset 25

	uint32_t	fDVErrCntr;		// offset 26
	uint32_t	minLat;			// offset 27
	uint32_t	maxLat;			// offset 28
	uint32_t	minJitt;		// offset 29
	uint32_t	maxJitt;		// offset 30
	uint32_t	latBkt0;		// offset 31
	uint32_t	latBkt1;		// offset 32
	uint32_t	latBkt2;		// offset 33
	uint32_t	latBkt3;		// offset 34
	uint32_t	jittBkt0;		// offset 35
	uint32_t	jittBkt1;		// offset 36
	uint32_t	jittBkt2;		// offset 37
	uint32_t	jittBkt3;		// offset 38
};

typedef struct pmStatsRamLmmEntry_s pmStatsRamLmmEntry_t;
struct pmStatsRamLmmEntry_s {
	svcEn_t		enFL;			// offset 0
	uint8_t		fltDiv128;		// offset 0
	uint8_t		firstLmr;		// offset 0
	uint32_t	fLThres;		// offset 0
	uint8_t		dtlPm;			// offset 0
	uint8_t		sESFlg;			// offset 0
	uint8_t		eSFlg;			// offset 0
	uint32_t	lastNeTx;		// offset 1
	uint32_t	lastFeRx;		// offset 2
	uint32_t	neTxCntr;		// offset 3
	uint32_t	feRxCntr;		// offset 4
	uint32_t	lastFeTx;		// offset 5
	uint32_t	lastNeRx;		// offset 6
	uint32_t	feTxCntr;		// offset 7
	uint32_t	neRxCntr;		// offset 8

	uint16_t	lMepNum;		// offset 15
	uint16_t	rMepNum;		// offset 15
	uint8_t		enAlm;			// offset 15

};

typedef struct pmStatsRamDelayBinEntry_s {
	uint32_t	latBkt0;		// offset 31
	uint32_t	latBkt1;		// offset 32
	uint32_t	latBkt2;		// offset 33
	uint32_t	latBkt3;		// offset 34
	uint32_t	jittBkt0;		// offset 35
	uint32_t	jittBkt1;		// offset 36
	uint32_t	jittBkt2;		// offset 37
	uint32_t	jittBkt3;		// offset 38
} pmStatsRamDelayBinEntry_t;

typedef struct pmStatsRamDmmEntry_s pmStatsRamDmmEntry_t;
struct pmStatsRamDmmEntry_s {
	uint16_t	lMepNum;		// offset 15
	uint16_t	rMepNum;		// offset 15
	uint8_t		enAlm;			// offset 15
	uint32_t	lastJitter;		// offset 16
	uint32_t	lastDelay;		// offset 17
	uint32_t	fDPktCntr;		// offset 18
	uint32_t	sumLatLow;		// offset 19
	uint32_t	sumLatUpp;		// offset 20
	uint32_t	sumJittLow;		// offset 21
	uint32_t	sumJittUpp;		// offset 22
	uint8_t		firstRx;		// offset 23
	svcEn_t		enFD;			// offset 23
	uint32_t	fDThres;		// offset 23
	uint8_t		fD1SErrCntr;	// offset 23
	uint32_t	fDErrCntr;		// offset 24
	uint32_t	fDVThres;		// offset 25
	uint8_t		fDV1SErrCntr;	// offset 25

	uint32_t	fDVErrCntr;		// offset 26
	uint32_t	minLat;			// offset 27
	uint32_t	maxLat;			// offset 28
	uint32_t	minJitt;		// offset 29
	uint32_t	maxJitt;		// offset 30
	uint32_t	latBkt0;		// offset 31
	uint32_t	latBkt1;		// offset 32
	uint32_t	latBkt2;		// offset 33
	uint32_t	latBkt3;		// offset 34
	uint32_t	jittBkt0;		// offset 35
	uint32_t	jittBkt1;		// offset 36
	uint32_t	jittBkt2;		// offset 37
	uint32_t	jittBkt3;		// offset 38
};
typedef struct pmDbRamEntry_s pmDbRamEntry_t;
struct pmDbRamEntry_s {
	uint32_t	fLThres;
	uint8_t		dtlPm;
	uint8_t		sESFlg;
	uint8_t		eSFlg;
	uint8_t		fL1SPktCntr;
	uint32_t	fDThres;
	uint8_t		fD1SErrCntr;
	uint32_t	fDErrCntr;
	uint32_t	fDPktCntr;
	uint32_t	fDVThres;
	uint8_t		fDV1SErrCntr;
	uint32_t	lastDelay;
	uint32_t	fDVErrCntr;
	uint32_t	sESCntr;
	uint32_t	eSCntr;
};

typedef struct lmDbRamEntry_s lmDbRamEntry_t;
struct lmDbRamEntry_s {
	uint32_t	fLThres;
	uint8_t		dtlPm;
	uint8_t		sESFlg;
	uint8_t		eSFlg;
	uint8_t		fL1SPktCntr;
};

typedef struct dmDbRamEntry_s dmDbRamEntry_t;
struct dmDbRamEntry_s {
	uint8_t		fD1SErrCntr;
	uint8_t		fDV1SErrCntr;
	uint8_t		enFD;
	uint8_t		firstRx;
	uint32_t	fDThres;
	uint32_t	fDErrCntr;
	uint32_t	fDPktCntr;
	uint32_t	fDVThres;
	uint32_t	lastDelay;
	uint32_t	fDVErrCntr;
	uint32_t	lastVar;
	uint32_t	minLat;
	uint32_t	maxLat;
	uint32_t	minJitt;
	uint32_t	maxJitt;
	uint32_t	latBkt0;
	uint32_t	latBkt1;
	uint32_t	latBkt2;
	uint32_t	latBkt3;
	uint32_t	jittBkt0;
	uint32_t	jittBkt1;
	uint32_t	jittBkt2;
	uint32_t	jittBkt3;
};

typedef struct lbrRamEntry_s lbrRamEntry_t;
struct lbrRamEntry_s {
	uint8_t		multicast;
	uint32_t	lastLat;
	uint32_t	lastJitt;
	uint32_t	expSN;
	uint32_t	numRxLbr;
	uint32_t	minJitt;
	uint32_t	maxJitt;
	uint32_t	minLat;
	uint32_t	maxLat;
	uint32_t	sumLatLow;
	uint32_t	sumLatUpp;
	uint32_t	sumJitLow;
	uint32_t	sumJitUpp;
};

typedef struct pmNumRamEntry_s pmNumRamEntry_t;
	struct pmNumRamEntry_s {
		valid_t		pmValid;
		svcEn_t		lossTxEn;
		svcEn_t		delayTxEn;
		svcEn_t		idmSvcEn;
		svcEn_t		slmSvcEn;
		svcEn_t		dmmSvcEn;
		interval_t	lossInt;
		interval_t	delayInt;
		iFace_t		iFace;
	};

typedef struct evcTblEntry_s {
	uint16_t	txVid;
	pushTag_t	pushTagType;
	tagAction_t	tagAction;
	uint8_t		cosDscp;
	uint8_t		usePcpEvcCol;
	uint8_t		cosPreserve;
} evcTblEntry_t;

typedef struct cfmTblEntry_s {
	mdLevel_t	rxHighestMepLevel;			// The highest level MEP on this port (not MIPs)
	bool		rxHighestMepLevelVal;
	mdLevel_t	txHighestMepLevel;			// The highest level MEP on the opposite port (not MIPs)
	bool		txHighestMepLevelVal;
} cfmTblEntry_t;

typedef struct pcpEntry_s {
	prio_t	priority;
	bool	de;
} pcpEntry_t;

typedef struct flowNumEntry_s {
	uint8_t		colFwd;
	uint8_t		colAware;
	uint8_t		pcpEvcCol;
	uint8_t		pcpDiscard;
	uint16_t	flowNum;
	prio_t		mapPcpPrio;
} flowNumEntry_t;

#endif
