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

/*!
 *\file
 *\brief
 *		 Project wide Constants
 */

#ifndef __MR_CONSTANTS_H__
#define __MR_CONSTANTS_H__

#ifndef PHY_COUNT
#	define PHY_COUNT 		(3)
#endif

/* -----------------------------------------------------------------------*/
/* Define Constants for Hardware Restrictions  */
/* THESE VALUE CAN BE MODIFIED BY THE CUSTOMER */
/* -----------------------------------------------------------------------*/
#define MR_MAX_PORTS				(2)		// This value should match the Hardware - max number of ports supported
#define MR_DEFAULT_PORT				(0)		// The default port to use if in Demarcation mode - Depends on HW support
#define MR_DEFAULT_DIR				(0)		// up = 1, down = 0.
#define MR_MAX_VLANS				(0x1000)	// there are a max of 4096 Vlans

/* -----------------------------------------------------------------------*/

/* -----------------------------------------------------------------------*/
/*                DO NOT MODIFY VALUES BELOW THIS POINT					  */
/* -----------------------------------------------------------------------*/

/* -----------------------------------------------------------------------*/
/* Define Constants for Hardware Restrictions*/
/* -----------------------------------------------------------------------*/
#define MR_DETAILED_PM_FIFO_DEPTH 	32
#define MR_LBR_1SEC_FIFO_DEPTH 		8


/* -----------------------------------------------------------------------*/
/* Define Constants for LoopBack Response Memory access*/
/* -----------------------------------------------------------------------*/
#define MR_LBR_LB_CFG_OFFSET		256		// The offset to the LB Rx Config Info within the LBR Ram
#define MR_LB_1SEC_FIFO_OFFSET		16		// This is the offset in dwords to the 1 Sec sampling FIFO in every LBR entry
#define MR_LB_1SEC_FIFO_SIZE		8		// This is the depth in dwwords of the 1 Sec Sampling FIFO
#define MR_LB_MC_MAC_OFFSET			384		// LBR ram is 64 bits wide. The FIFO is located at offset 192 (2*192=364)

/* -----------------------------------------------------------------------*/
/* Define Constants used for identifying directions on actions or services */
/* -----------------------------------------------------------------------*/
#define MR_TX_ONLY		1
#define MR_RX_ONLY		2
#define MR_BOTH_TX_RX	3

/* -----------------------------------------------------------------------*/
/* Define Constants used to represent NULL values for RAM Table entries */
/* -----------------------------------------------------------------------*/

#define	MR_NULL_PORT_ID			0xFF
#define MR_NULL_VLAN			0xFFF

/* -----------------------------------------------------------------------*/
/* Define Constants used in Common CFM entries in the Tx Templates RAM */
/* -----------------------------------------------------------------------*/

#define	MR_LMEP_HANDLE_MASK		0x00004000



/* -----------------------------------------------------------------------*/
/* Define Constants used in Common CFM entries in the Tx Templates RAM */
/* -----------------------------------------------------------------------*/
#define	MR_CCM_1ST_OFF 		70
#define	MR_LB_1ST_OFF 		4
#define	MR_LMM_1ST_OFF 		12
#define	MR_DMM_1ST_OFF		32
#define	MR_IDM_1ST_OFF		16
#define MR_LTM_1ST_OFF		17
#define MR_LTR_1ST_OFF		6

#define	MR_CCM_OPCODE		1
#define	MR_LBR_OPCODE		2
#define	MR_LBM_OPCODE 		3
#define	MR_LTR_OPCODE 		4
#define	MR_LTM_OPCODE 		5
#define	MR_TST_OPCODE		37
#define	MR_LMR_OPCODE		42
#define	MR_LMM_OPCODE		43
#define	MR_IDM_OPCODE		45
#define	MR_DMR_OPCODE		46
#define	MR_DMM_OPCODE		47

/* -----------------------------------------------------------------------*/
/* Define TLV type constants */
/* -----------------------------------------------------------------------*/
#define	MR_END_TLV_TYPE				0
#define	MR_SID_TLV_TYPE				1
#define	MR_ORG_TLV_TYPE				31
#define	MR_PS_TLV_TYPE				2
#define	MR_IS_TLV_TYPE				4
#define	MR_REPLY_IGRESS_ID_TLV_TYPE	5
#define	MR_REPLY_EGRESS_ID_TLV_TYPE	6
#define	MR_LTM_EGRESS_ID_TLV_TYPE	7
#define	MR_LTR_EGRESS_ID_TLV_TYPE	8

#define	MR_LTM_EGRESS_ID_LENGTH				8
#define	MR_MAX_VALID_LTR_RELAY_ACTION		3		// Any value greater than this is invalid
#define	MR_MAX_VALID_REPLY_INGRESS_ACTION	4		// Any value greater than this is invalid
#define	MR_MAX_VALID_REPLY_EGRESS_ACTION	4		// Any value greater than this is invalid
/* -----------------------------------------------------------------------*/
/* Common CFM Header Flag Constants */
/* -----------------------------------------------------------------------*/
#define	MR_CHDR_LTM_USE_FDB_ONLY	0x80
#define	MR_CHDR_LTR_USE_FDB_ONLY	0x80
#define	MR_CHDR_LTR_FWD_YES			0x40
#define	MR_CHDR_LTR_TERM_MEP		0x20
/* -----------------------------------------------------------------------*/
// CPU Packet Capture constants
/* -----------------------------------------------------------------------*/
#define	MR_CPU_CAPT_FIFO_SIZE		2048		// The size in Bytes of Wan/Lan Capture buffer
#define	MR_CPU_CAPT_INFO_FIFO_SIZE	256

#define	MR_EFM_MISC_PKT 			0x10
#define	MR_EFM_EVENT_NOTIF_PKT 		0x11
#define	MR_EFM_VAR_REQ_PKT 			0x12
#define	MR_EFM_VAR_RESP_PKT 		0x13
#define	MR_EFM_LB_CTRL_PKT 			0x14
#define	MR_EFM_ORG_SPECIFIC_PKT 	0x15
#define	MR_EFM_INFO_WITH_ORG_PKT 	0x16

#define	MR_DA_MATCH_DEV_RSVD_PKT 	0x18
#define	MR_DA_MATCH_802_RSVD_PKT 	0x19
#define	MR_DA_MATCH_MGMT_MAC_PKT 	0x1A

#define	MR_OAM_LTR_PKT			 	0x04
#define	MR_OAM_LTM_PKT			 	0x05
#define	MR_OAM_AIS_PKT			 	0x21
#define	MR_OAM_LCK_PKT			 	0x23
#define	MR_OAM_TST_PKT			 	0x25
#define	MR_OAM_ASP_PKT			 	0x27
#define	MR_OAM_EXR_PKT			 	0x30
#define	MR_OAM_EXM_PKT			 	0x31
#define	MR_OAM_VSR_PKT			 	0x32
#define	MR_OAM_VSM_PKT			 	0x33

/* -----------------------------------------------------------------------*/
// Constants used in Y1564/RFC2544 test
/* -----------------------------------------------------------------------*/
#define MR_AVAIL_THRESH			10		// Used to set the filter/hysterysis depth for availability filter
#define MR_TST_MAX_START		3		// Sets the max No of zero'd samples to skip before forcing test start
#define	MR_MAX_DMM_PER_RMEP		16		// Set the number of DMM serivices allowed per remote MEP

/* -----------------------------------------------------------------------*/
// MASK bits for identifying TLV Change in ISR report
/* -----------------------------------------------------------------------*/
#define	MR_PS_TLV_CHANGE_MASK	0x01
#define	MR_IS_TLV_CHANGE_MASK	0x02
#define	MR_ORG_TLV_CHANGE_MASK	0x04
#define	MR_SID_TLV_CHANGE_MASK	0x08

/* -----------------------------------------------------------------------*/
// General Constants used for masking commonly used fields
/* -----------------------------------------------------------------------*/
#define	MR_TAG_VLAN_MASK			0x00000FFF
#define	MR_TAG_VLAN_OFFSET			0
#define	MR_TAG_DE_MASK				0x00001000
#define	MR_TAG_DE_OFFSET			12
#define	MR_TAG_PRIO_MASK			0x0000E000
#define	MR_TAG_PRIO_OFFSET			13

#define	MR_BYTE0_MASK			0x000000FF
#define	MR_BYTE1_MASK			0x0000FF00
#define	MR_BYTE2_MASK			0x00FF0000
#define	MR_BYTE3_MASK			0xFF000000
#define	MR_BYTE0_OFFSET			0
#define	MR_BYTE1_OFFSET			8
#define	MR_BYTE2_OFFSET			16
#define	MR_BYTE3_OFFSET			24
#define	MR_WORD0_MASK			0x0000FFFF
#define	MR_WORD1_MASK			0xFFFF0000
#define	MR_WORD0_OFFSET			0
#define	MR_WORD1_OFFSET			16
#define	MR_DWORD_MASK			0xFFFFFFFF

#define MR_MAX_ITERS			10				// Set the maximum number of iterations when polling a flag

#endif
