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

#ifndef LB_SUPPORT_H_
#define LB_SUPPORT_H_

#include <api_oam_sdk/common/types/inc/mr_api_types.h>
#include <api_oam_sdk/loopback/inc/lb.h>
#include "egl_types.h"

#define MAX_LB_CHANNELS				(1)			// The number of HW engines to support LB
#define MAX_LB_CHANNELS_FOR_Y1564	(8)			// The number of HW engines to support Y1564 and RFC2544
#define MAX_LB_NUM_BURSTS			(2047)		// The maximum number of Loopback burst that are supported
#define MAX_LB_PKTS_PER_BURSTS		(1023)		// The maximum number of packets that can be in a Loopback burst
#define MAX_LB_DATA_TLV				(10000)		// The maximum size of the Data TVL appended to the LBM packet
#define MAX_LB_LBM_STORES			(8)			// The Number of Received LBMs Stats that can be maintained simultaneously
#define MAX_LBM_PKT_SIZE			(0x3FFF)	// The Maximum packet size of a LBM packet (transmit)
#define MAX_LB_IBG_USEC				(0x1FFFFF)	// The Maximum time, in micro-seconds, that can be set for the inter-burst gap
#define MAX_LB_MULTICAST_RX_LIST_SIZE	(64)// The Maximum number of LBR SA MACs that can be saved
typedef struct
{
	uint16_t	callingLMepNum;				// holds the lMepNum of the MEP that this LB channel is assigned to (if inUse == true)
	bool		inUse;						// True if this channel is in use by a MEP
	bool		locked;						// True if this channel is locked for use by another module (e.g. Y1564/RFC2544)
	bool		inAdvancedMode;				// True if the channel is being used in advanced mode (i.e. non-standard CFM operation)
} lbMgnt_t;

typedef struct
{
	uint16_t	lMepNum;
	uint8_t		pcp;
	uint8_t		multicast;
	uint8_t		active;
} lbSvc_t;

typedef struct
{
	mepLbInfo_t			mepLbInfo;
	mepLbMefInfo_t		mepLbMefInfo;
	mepLbTxAdvanceCfg_t	mepLbAdvInfo;
	mepLbAdvanceStats_t mepLbAdvStats;
	bool				readFromHwRequired;
} lbEntry_t;


int initLB(void);
int addLBSvcToLMep(uint16_t lMepNum,uint8_t multiCast,uint8_t mdLvl,txTemplateEntry_t *txLbTempl,templateType_t templType,uint8_t dirCfgMask,uint8_t lbChnl);
int enableLBChnl(uint8_t lbChnl);
int disableLBChnl(uint8_t lbChnl,uint8_t selDir);
int removeLBSvc(uint8_t lbChnl);
int clrLBTxStats(void);
int clrLBRxStats(uint8_t lbChnl,uint32_t seqNum);
int readLBStats(uint8_t lbChnl, lbStats_t *lbStats);
int resetLBSeqNum(uint8_t lbChnl, uint32_t seqNum);
int enableLB(uint16_t lbChnlMask, uint8_t dirSel);
int disableLB(uint16_t lbChnlMask, uint8_t dirSel);
int disableLBTx(uint16_t lbChnlMask);
int disableLBTxChnl(uint8_t lbChnl);
bool isLbActive(uint8_t chnlNum);

#endif /* LB_SUPPORT_H_ */
