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

#ifndef SVC_BWP_TYPES_H_
#define SVC_BWP_TYPES_H_

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


typedef int8_t bwpNum_t;

typedef struct
{
	bwpGrpIndex_t	bwpGrpIndex;						// The BWP Group index for this BWP Group
	bool			inUse;								// Used to indicate that an entry is in use
} bwpGrpCtxt_t;

struct bwpGrpEntry_s
{
	TAILQ_ENTRY(struct bwpGrpEntry_s,) 				ll;
	bwpGrpCtxt_t									bwpGrpCtxt;
	bwpIndex_t										bwpNextIndex;	// The index of the next BWP in this group
	TAILQ_HEAD(llBwpHead_s,struct bwpEntry_s,)		llBwpHead;		// The Linked list head, used to access the BWP list for this BWP Group
};

typedef struct bwpGrpEntry_s bwpGrpEntry_t;

typedef struct
{
	bwpIndex_t	bwpIndex;								// The BWP index for this BWP
	bwpNum_t	bwpNum;									// Hardware index associated with this BWP
	bool		inUse;									// Used to indicate that an entry is in use
} bwpCtxt_t;

struct bwpEntry_s
{
	TAILQ_ENTRY(struct bwpEntry_s,) 	ll;
	svcBwpCfg_t							cfg;
	bwpCtxt_t							bwpCtxt;
};

typedef struct bwpEntry_s bwpEntry_t;

#define MAX_NUM_BWP		(75)				// The Maximum number of BWP profiles supported by the system
#define INVALID_BWP_NUM	(-1)

void setBwpLogLevel(log_level_t logLevel);

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

bool svcBwpGrpIsBwpGrpIndexValid(bwpGrpIndex_t bwpGrpIndex);

bool svcBwpIsBwpIndexValid(bwpGrpIndex_t bwpGrpIndex, bwpIndex_t bwpIndex);

/*
 * TODO: add comments
 */
int svcBwpGrpAddToEvc(evcNum_t evcNum, iFace_t iFace, bwpGrpIndex_t bwpGrpIndex);

bool _bwpIsCosIndexInUse(cosIndex_t cosIndex);

#endif /* SVC_BWP_TYPES_H_ */
