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


#ifndef SVC_EVC_TYPES_H_
#define SVC_EVC_TYPES_H_

#include <api_oam_sdk/service_evc/inc/svc_evc.h>
#include <api_oam_sdk/service_uni/src/svc_uni_types.h>
#include "egl_log.h"

#define MAX_NUM_EVCS		(8)//(64) // changed from 64 to 8
#define INVALID_EVC_NUM		(-1)
#define INVALID_FLOW_NUM	(-1)
#define PORT_ASSIGNED_EVC	(126)

typedef int8_t evcNum_t;

typedef struct
{
	evcIndex_t	evcIndex;								// The MIB index for this EVC
	evcNum_t	evcNum;
	bool		inUse;									// Used to indicate that an entry is in use
	bool		mepOnEvc;								// If true, indicates a MEP is on this EVC
	bool		svcEvc;									// If true, indicates a Data Service is on this EVC
} evcCtxt_t;

typedef struct {
	evcUniCfg_t							evcUniCfg;
	evcPerUniCfg_t						evcPerUniCfg;
	evcPerUniEglCfg_t					evcPerUniEglCfg;
} evcUniPerUniCfg_t;

struct evcEntry_s
{
	TAILQ_ENTRY(struct evcEntry_s,) 	ll;
	evcCtxt_t							evcCtxt;
	evcCfg_t							cfg;
	evcUniPerUniCfg_t					uniCfg[MAX_NUM_UNIS];
};

typedef struct evcEntry_s evcEntry_t;

typedef struct
{
	TAILQ_HEAD(llEvcHead_s,struct evcEntry_s,)	llEvcHead;			// The Linked list head, used to access the EVC list
	evcIndex_t									evcNextIndex;		// The MIB index to use for the next EVC created
	evcNum_t									evcCount;			// Count of the number of configured EVCs
} evcList_t;

// Function Prototypes
void evcInit(void);

#if 0
evcNum_t	_evcIndexToEvcNum(evcIndex_t evcIndex);
#endif

void setEvcLogLevel(log_level_t logLevel);

bool svcEvcIsEvcIndexValid(evcIndex_t evcIndex);

bool evcCheckOrCreateEvcForMep(uint16_t Vlan, iFace_t iFace);

void setFlowTableDefaults(evcNum_t evcNum, iFace_t iFace, bool pcpDiscard);

bool _evcIsBwpGrpInUse(bwpGrpIndex_t bwpGrpIndex);

bool _evcIsL2cpGrpInUse(l2cpGrpIndex_t l2cpGrpIndex);

evcIndex_t _evcNumToMibIndex(evcNum_t evcNum);

void restoreInterfaceFilteredVlans(iFace_t iFace, uint16_t *filtList, uint16_t listLen);

#endif /* SVC_EVC_TYPES_H_ */
