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

#ifndef SYSTEM_H_
#define SYSTEM_H_

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

extern const char *maIntervalStr[8];

uint16_t vidPrioDeToTag(uint16_t vlan, uint8_t prio, bool de);
void getInterfaceMAC(iFace_t iFace, macAddress_t	macAddress);
uint16_t getPortDefaultLan(iFace_t iFace);
void getPortDefaultVid(iFace_t iFace, pVidEntry_t *pVidEntry);
psValue_t sysGetPortStatus(iFace_t iFace);
isValue_t sysGetInterfaceStatus(iFace_t iFace);
void sysPortStatusChangeCB(iFace_t iFace, psValue_t psValue);
void sysInterfaceStatusChangeCB(iFace_t iFace, isValue_t isValue);
bool mepIdIsValid(mepId_t mepId);
void generatePacketTags(
		tagEntry_t	*innerTag,
		tagEntry_t	*outerTag,
		uint16_t 	vLan,
		prio_t		prio,
		bool		de,
		tagType_t	tagType,
		iFace_t		iFace);

void generateBasicCfmTemplate(lMepNum_t lMepNum,iFace_t iFace,uint16_t pktSize,tagEntry_t *innerTag,tagEntry_t *outerTag,txTemplateEntry_t *txTemplateEntry);

/*
 * @brief Returns the priority that achieves the lowest Frame Loss
 */
prio_t	sysGetLowestFrameLossPrio(void);

/*
 * @brief This will disable the CFM Tx Hardware
 */
void cfmTxEnable(bool enable);

/*
 * @brief Sets the LOS signal on the MSA interface in the SFP hardware
 * Loss Of Signal (LOS) should be asserted when the SFP data path is
 * inaccessible to the host systems. e.g. during early power up or
 * system update...or cable disconnect.
 */
void msaSetLOS(void);

/*
 * @brief Clears the LOS signal on the MSA interface in the SFP hardware
 * Loss Of Signal (LOS) should be de-asserted when the SFP data path is
 * accessible to the host systems.
 */
void msaClrLOS(void);

/*
 * @brief Requests that the Optics sub-system enabled the Tx Optics
 */
void msaEnableOptics(void);

/*
 * @brief Requests that the Optics sub-system disables the Tx Optics
 * This should be done prior to system field upgrade
 */
void msaDisableOptics(void);


/*
 * @brief This function is used to parse a COS/DSCP/VLAN MAP string and convert it to a list
 */
bool getListFromStringMap(char *strMap,uint16_t *listPtr, uint16_t minVal, uint16_t maxVal, uint16_t *listLen);

int enableMgntVlan(uint16_t mgntVlan);
void disableMgntVlan(void);
uint16_t getMgntVlan(void);


uint32_t	deltaFromNowInMs(struct timespec *tm);
int 		clock_time (struct timespec *tp);
int			clock_gettime_plus_ms_delay (struct timespec *tp, uint32_t delay);
void 		time_plus_ms_delay (struct timespec *tp, uint32_t delay);
bool		timeAisAfterTimeB(struct timespec *timeA,struct timespec *timeB);


#endif /* SYSTEM_H_ */
