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

#ifndef LINK_TRACE_CONFIG_H_
#define LINK_TRACE_CONFIG_H_

#include <api_oam_sdk/common/types/inc/mr_api_types.h>
#include <api_oam_sdk/link_trace/src/link_trace_types.h>
#include <api_oam_sdk/maintenance_association/inc/ma.h>
#include "time.h"

#include "osal.h"

#define MR_GEN_VAL_TAG(v,p,d) (((((uint16_t)v) << MR_TAG_VLAN_OFFSET) & MR_TAG_VLAN_MASK) |  \
								((((uint16_t)p) << MR_TAG_PRIO_OFFSET) & MR_TAG_PRIO_MASK)| \
								((((uint16_t)d) << MR_TAG_DE_OFFSET) & MR_TAG_DE_MASK) )


typedef struct OS_PACKED_STRUCT {
	uint8_t 	DA[6];
	uint8_t		SA[6];
	uint16_t	eType;
} ethHdr_t;

typedef struct OS_PACKED_STRUCT {
	uint8_t	lvlVer;
	uint8_t	opCode;
	uint8_t	flags;
	uint8_t	firstOS;
} commonCfm_t;

typedef struct OS_PACKED_STRUCT {
	uint8_t		type;
	uint16_t	length;
	uint8_t		egressId[8];
} ltmEgressIdTlv_t;

typedef struct OS_PACKED_STRUCT {
	commonCfm_t			ccmHdr;
	uint32_t			transitId;
	uint8_t				ttl;
	uint8_t				origMAC[6];
	uint8_t				targetMAC[6];
	ltmEgressIdTlv_t	ltmEgressIdTlv;
	uint8_t				tlvStart;
} ltmHeader_t;

typedef struct OS_PACKED_STRUCT {
	commonCfm_t		ccmHdr;
	uint32_t		transitId;
	uint8_t			ttl;
	uint8_t			relayAct;
	uint8_t			tlvStart;
} ltrHeader_t;

typedef struct OS_PACKED_STRUCT {
	uint8_t		type;
	uint16_t	length;
	uint8_t		lastEgressId[8];
	uint8_t		nextEgressId[8];
} ltrEgressIdTlv_t;

typedef struct OS_PACKED_STRUCT {
	uint8_t		type;
	uint16_t	length;
	uint8_t		action;
	uint8_t		mac[6];
	uint8_t		portIdLen;
	uint8_t		portIdSubtype;
	uint8_t		portId[MR_PORT_ID_SIZE];		// size should be variable!!
} replyTlv_t;

typedef struct ltmReplyListEntry_s ltmReplyListEntry_t;
struct ltmReplyListEntry_s
{
	ltmReplyListEntry_t	*ltmReplyListNext;
	ltmTxInfo_t 		ltmTxInfo;
	uint32_t			transitId;
	struct timespec 	txTime;
	ltrReplyListEntry_t	*ltrReplyList;
	volatile boolean_t	timedOut;
	volatile boolean_t	harvested;
	mdIndex_t 			mdIndex;
	maIndex_t 			maIndex;
	mepId_t				lMepId;
	lMepNum_t			_lMepNum;
	uint16_t			ltrReplyCount;
	uint16_t			ltrReadCount;
};

#endif /* LINK_TRACE_CONFIG_H_ */
