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

#ifndef SVC_L2CP_TYPES_H_
#define SVC_L2CP_TYPES_H_

#include <api_oam_sdk/common/types/inc/linked_list.h>
#include <api_oam_sdk/service_evc/src/svc_evc_types.h>
#include <api_oam_sdk/service_l2cp/inc/svc_l2cp.h>
#include "egl_types.h"
#include "egl_log.h"


typedef int8_t l2cpNum_t;

typedef struct
{
	l2cpGrpIndex_t	l2cpGrpIndex;						// The L2CP Group index for this L2CP Group
	bool			inUse;								// Used to indicate that an entry is in use
} l2cpGrpCtxt_t;

struct l2cpGrpEntry_s
{
	TAILQ_ENTRY(struct l2cpGrpEntry_s,) 			ll;
	l2cpGrpCtxt_t									l2cpGrpCtxt;
	l2cpIndex_t										l2cpNextIndex;	// The index of the next l2cp in this group
	TAILQ_HEAD(llL2cpHead_s,struct l2cpEntry_s,)	llL2cpHead;	// The Linked list head, used to access the L2CP list for this L2CP Group
};

typedef struct l2cpGrpEntry_s l2cpGrpEntry_t;

typedef struct
{
	l2cpIndex_t	l2cpIndex;								// The L2CP index for this L2CP
	l2cpNum_t	l2cpNum;								// Hardware index associated with this L2CP
	bool		inUse;									// Used to indicate that an entry is in use
} l2cpCtxt_t;

struct l2cpEntry_s
{
	TAILQ_ENTRY(struct l2cpEntry_s,) 	ll;				// control/manage the Linked List
	svcL2cpCfg_t						cfg;			// The L2CP configuration
	l2cpCtxt_t							l2cpCtxt;		// The local context for the L2CP
};

typedef struct l2cpEntry_s l2cpEntry_t;

#define MAX_NUM_L2CP_GRPS	(1)				// The Maximum number of L2CP Groups supported by the system
#define MAX_NUM_L2CP		(32)				// The Maximum number of L2CP profiles supported by the system
#define INVALID_L2CP_NUM	(-1)				// A value used to represent an invalid L2CP number

void setL2cpLogLevel(log_level_t logLevel);

/*
 * @brief Should be called at system startup to initialise the L2CP Module.
 */
void l2cpInit(void);

bool svcL2cpGrpIsL2cpGrpIndexValid(l2cpGrpIndex_t l2cpGrpIndex);

bool svcL2cpIsL2cpIndexValid(l2cpGrpIndex_t l2cpGrpIndex, l2cpIndex_t l2cpIndex);

void addL2CPGroupToInterface(iFace_t iFace, l2cpGrpIndex_t l2cpGrpIndex);

#endif /* SVC_L2CP_TYPES_H_ */
