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

#ifndef TABLE_ACCESS_CONSTANTS_H_
#define TABLE_ACCESS_CONSTANTS_H_

#include <api_oam_sdk/maintenance_association/src/ma_types.h>
#include <api_oam_sdk/performance_monitoring/src/pm_config.h>

	/* -----------------------------------------------------------------------*/
	/* Define Constants used for RAM sizing */
	/* Note: ENTRY_SIZEs are multiples of 32-bits, i.e. 1 location in Ext Ram */
	/* -----------------------------------------------------------------------*/
	#define	VLAN_PORT_ENTRY_SIZE		(1)
	#define	SEQ_ERR_ENTRY_SIZE			(16)		// This is now at offset 15 in LMep(MAID) table
	#define	LMEP_ENTRY_SIZE				(16)		// previously 13
	#define	RMEP_ENTRY_SIZE				(1)
	#define	DB_ENTRY_SIZE				(22)		//
	#define	CCM_TX_TEMPL_ENTRY_SIZE		(22)		//
	#define	CCM_TX_TEMPL_HIGHEST_OSET	(21)		// This is the location that holds the hidden data
	#define	PM_TX_TEMPL_ENTRY_SIZE		(9)			//
	#define	PM_TX_TEMPL_HIGHEST_OSET	(8)			// This is the location that holds the hidden data
	#define	LB_TX_TEMPL_ENTRY_SIZE		(16)		// these entries are 2048 bytes.
	#define	LB_TX_TEMPL_HIGHEST_OSET	(15)		// This is the location that holds the hidden data
	#define	PM_STATS_ENTRY_SIZE			(40)		//
	#define	LBR_ENTRY_SIZE				(32)
	#define	MC_LBR_ENTRY_SIZE			(64)		// The number of MultiCast MACs that can be captured by Rx HW
	#define TX_LB_STAT_ENTRY_SIZE		(1)
	#define	RX_LMEP_NUM_ENTRY_SIZE		(2)			// Actually 1x23bits (word 1) and 1x13bits (word 0)
	#define MR_LVL_ROWS					(8)			// Number of rows required to hold Level info
	#define PROBE_STORE_RAM_DEPTH		(55)
	#define XCONN_STORE_RAM_DEPTH		(55)
	#define RMEP_ERR_STORE_RAM_DEPTH	(55)
	#define CPU_TX_PKT_ENTRY_SIZE		(512)		// Number of Dwords in the CPU Tx Pkt Buffer

	#define EVC_TBL_ENTRY_SIZE			(1)
	#define CFM_TBL_ENTRY_SIZE			(1)
	#define COS_RX_PCP_TBL_ENTRY_SIZE	(1)
	#define COS_TX_PCP_TBL_ENTRY_SIZE	(1)
	#define COS_DSCP_TBL_ENTRY_SIZE		(1)
	#define FLOW_NUM_TBL_ENTRY_SIZE		(1)

	#define POL_CFG_ENTRY_SIZE          (4)
	#define POL_STATS_ENTRY_SIZE        (4)

	#define MR_RMEP_TBL_SIZE			MAX_NUM_MEPS * MAX_RMEPS_PER_LM * RMEP_ENTRY_SIZE

	/* -----------------------------------------------------------------------*/
	/* Constants for Memory Base Addresses */
	/* -----------------------------------------------------------------------*/
	#define VLAN_PORT_0_BA				(0x0)
	#define VLAN_PORT_1_BA				(0x200000)

	#define MR_BA_RMEP_TBL				(0x200000)	// located at top of rxLMepRam (indirect RAM No.4)

	#define EVC_TBL_PORT_0_BA			(0x080000)
	#define EVC_TBL_PORT_1_BA			(0x280000)

	#define CFM_TBL_PORT_0_BA			(0x0C0000)
	#define CFM_TBL_PORT_1_BA			(0x2C0000)

	#define RX_LMEP_NUM_TBL_PORT_0_BA	(0)
	#define RX_LMEP_NUM_TBL_PORT_1_BA	(600 * RX_LMEP_NUM_ENTRY_SIZE)

	#define COS_RX_PCP_TBL_PORT_0_BA	(0x100000)
	#define COS_TX_PCP_TBL_PORT_0_BA	(0x100010)
	#define COS_DSCP_TBL_PORT_0_BA		(0x100040)
	#define COS_RX_PCP_TBL_PORT_1_BA	(0x300000)
	#define COS_TX_PCP_TBL_PORT_1_BA	(0x300010)
	#define COS_DSCP_TBL_PORT_1_BA		(0x300040)

	#define FLOW_NUM_TBL_PORT_0_BA		(0x180000)
	#define FLOW_NUM_TBL_PORT_1_BA		(0x380000)

	#define LBM_STORE_PORT_0_BA			(0x000000)
	#define LBM_STORE_PORT_1_BA			(0x200000)
	/* -----------------------------------------------------------------------*/
	/* Constants for Common Memory Access */
	/* -----------------------------------------------------------------------*/
	#define MR_BA_LMEP_TBL			(0)										// The offset address to the start of the Local MEP (MAID) table
	#define MR_LMEP_TBL_SIZE		(MAX_NUM_MEPS * LMEP_ENTRY_SIZE)

	// Sequence Error table shares RAM with LMEP table (offset 15)
	#define	MR_BA_SEQ_ERR			(MR_BA_LMEP_TBL + 15)					// The offset address to the start of the Sequence Error table
	#define	MR_SEQ_ERR_SIZE			(MAX_NUM_MEPS * SEQ_ERR_ENTRY_SIZE)

#ifndef POLICER
	#define	MR_BA_LB_TEMPL			(2048)									// The offset address to the start of the Loopback Tx Templates
	#define	MR_LB_TEMPL_SIZE		MAX_LB_CHANNELS_FOR_Y1564 * LB_TX_TEMPL_ENTRY_SIZE

	#define	MR_BA_CPU_PKT_TX		(2176)									// The offset address to the start of the CPU packet Tx buffer
	#define	MR_CPU_PKT_TX_SIZE		(CPU_TX_PKT_ENTRY_SIZE)

	#define	MR_BA_CCM_TEMPL			(2688)									// The offset address to the start of the CCM Tx Templates
	#define	MR_CCM_TEMPL_SIZE		(MAX_NUM_MEPS * CCM_TX_TEMPL_ENTRY_SIZE)

	#define	MR_BA_PM_TEMPL			(5504)									// The offset address to the start of the PM Tx Templates
	#define	MR_PM_TEMPL_SIZE		(MAX_NUM_PM_SERVICES * PM_TX_TEMPL_ENTRY_SIZE)

	#define	MR_BA_RMEP_DB			(7808)									// The offset address to the start of the Remote MEP DB
	#define	MR_RMEP_DB_SIZE			(MAX_NUM_MEPS * DB_ENTRY_SIZE)

	#define	MR_BA_PM_STATS			(10624)									// The offset address to the start of the PM stats
	#define	MR_PM_STATS_SIZE		(MAX_NUM_PM_SERVICES * PM_STATS_ENTRY_SIZE)
#else
	// There was a memory reduction introduced when the Policer was integrated in the design
	#define	MR_BA_LB_TEMPL			(1024)									// The offset address to the start of the Loopback Tx Templates
	#define	MR_LB_TEMPL_SIZE		MAX_LB_CHANNELS_FOR_Y1564 * LB_TX_TEMPL_ENTRY_SIZE

	#define	MR_BA_CPU_PKT_TX		(1152)									// The offset address to the start of the CPU packet Tx buffer
	#define	MR_CPU_PKT_TX_SIZE		(CPU_TX_PKT_ENTRY_SIZE)

	#define	MR_BA_CCM_TEMPL			(1664)									// The offset address to the start of the CCM Tx Templates
	#define	MR_CCM_TEMPL_SIZE		(MAX_NUM_MEPS * CCM_TX_TEMPL_ENTRY_SIZE)

	#define	MR_BA_PM_TEMPL			(3072)									// The offset address to the start of the PM Tx Templates
	#define	MR_PM_TEMPL_SIZE		(MAX_NUM_PM_SERVICES * PM_TX_TEMPL_ENTRY_SIZE)

	#define	MR_BA_RMEP_DB			(4224)									// The offset address to the start of the Remote MEP DB
	#define	MR_RMEP_DB_SIZE			(MAX_NUM_MEPS * DB_ENTRY_SIZE)

	#define	MR_BA_PM_STATS			(5632)									// The offset address to the start of the PM stats
	#define	MR_PM_STATS_SIZE		(MAX_NUM_PM_SERVICES * PM_STATS_ENTRY_SIZE)
#endif
	#define COS_RX_PCP_TBL_SIZE		(8)
	#define COS_TX_PCP_TBL_SIZE		(16)
	#define COS_DSCP_TBL_SIZE		(64)

	#define FLOW_NUM_TBL_SIZE		(MAX_NUM_EVCS * 8)
#endif /* TABLE_ACCESS_CONSTANTS_H_ */
