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

#ifndef SVC_UNI_H_
#define SVC_UNI_H_

#include <api_oam_sdk/common/types/inc/mr_api_types.h>
#include <api_oam_sdk/service_bwp/inc/svc_bwp.h>
#include <api_oam_sdk/service_evc/inc/svc_evc.h>
#include "egl_types.h"

typedef enum {
	allToOne			= 1,	// All to One Bundling, used for Private services: EPL, EP-LAN, and EP-Tree
	bundling			= 2,	// Bundling, indicates one or more CE-VLANS per service, used for virtual private CE-VLAN preservation services:EVPL, EVP-LAN, EVP-Tree
	multiplex			= 3,	// Service Multiplexing, indicates one or more EVCs per UNI, used for virtual private CE-VLAN preservation or non-preservation services: EVPL, EVP-LAN, EVP-Tree
	bundlingMultiplex	= 4		// Service Multiplexing plus Bundling, indicates one or more EVCs per UNI that are composed of one or more CE-VLANs, used for virtual CE-VLAN preservation services:EVPL, EVP-LAN, EVP-Tree
} bundlingMultiplex_t;

typedef enum {
	uniParam_bundlingMultiplex	= 1,	// The write parameter value to select the bundlingMultiplex type.
	uniParam_ceVlanUntagged		= 2,	// The write parameter value to select the vlan to use for untagged frames.
	uniParam_cePriorityUntaged	= 3,	// The write parameter value to select the priority to use for untagged frames.
} uniWrParam_t;

typedef struct svcUniCfg_s {
	uint16_t				ceVlanUntagged;		// Configures the CE VLAN ID associated with untagged and priority Service Frames.
	bundlingMultiplex_t		bundlingMultiplex;	// Configures bundling and multiplexing options for the UNI.
	prio_t					cePriorityUntaged;	// Configures the CE VLAN Priority associated with untagged Service Frames. It allows the assignment of a specific VLAN priority to untagged traffic.
} svcUniCfg_t;

/*
 * @brief Create a new UNI.
 *
 * Create a new UNI service using the configuration
 * parameters provided.
 *
 * @param[in] uni the index value of uni to create.
 * @param[in] svcUniCfg A pointer to a svcUniCfg_t data type  containing configuration values.
 * @return
 * \li 1: Operation rejected due to invalid or nonexistent UNI index.
 * \li 2: Operation rejected due to invalid type value
 * \li 3: Operation rejected due to invalid ceVlanUntagged value
 * \li 4: Operation rejected due to invalid ceCosUntagged value
 * \li 5: Operation accepted.
 */
int svcUniCreate(iFace_t uni, svcUniCfg_t *svcUniCfg);

/**
 * @brief	Delete the UNI with the supplied UNI index.
 *
 * This will delete the selected UNI and any associations with EVCs.
 *
 * @param[in] uni the index value of UNI to delete.
 * @returns
 * \li 1: Operation rejected due to invalid or nonexistent UNI
 * \li 2: Operation accepted
 *
 */
int svcUniDelete(iFace_t uni);

/*
 * @brief Read the service UNI configuration for the specified interface.
 *
 * Read information related to this service UNI. If a NULL pointer is supplied for
 * svcUniCfg then no information is returned for that parameter.
 * Information is only valid if the return value is 2.
 *
 * @param[in] iFace The index value of the interface to read from.
 * @param[out] svcIfaceCfg A pointer to a svcIfaceCfg_t data type or NULL. If not NULL its values will be updated.
 * @return
 * \li 1: Operation rejected due to invalid or nonexistent interface.
 * \li 2: Operation accepted.
 */
int svcUniRead(iFace_t iFace, svcUniCfg_t *svcUniCfg);

#if 0 		// UNI attributes are set at creation!
/**
 * @brief	Write a new value to the selected service UNI parameter.
 *
 * The writable parameters for an service UNI and the associated data type are:
	uniParam_bundlingMultiplex		bundlingMultiplex_t
	uniParam_ceVlanUntagged			uint16_t
	uniParam_cePriorityUntaged		prio_t
 *
 * Write a new value to a writable parameter of the service Interface. The ifaceParam value
 * is used to select one of the valid writable parameters (listed above) and the paramValue
 * is a pointer to the new value. The data type of the parameter (also listed above)
 * must be valid for the parameter or errors/misconfigurations may occur.
 *
 * @param[in] iFace selects the interface to write the parameter to.
 * @param[in] wrParam is an enum value that identifies the service UNI parameter to write to.
 * @param[in] paramValue Is a pointer to the new value for the selected parameter
 * @returns
 * \li 1: Operation rejected due to invalid or nonexistent iFace or EVC
 * \li 2: Operation rejected due to the selected managed object being Read-Only
 * \li 3: Operation rejected due to invalid value for parameter
 * \li 4: Operation accepted
 */
int svcUniWrite(iFace_t iFace, uniWrParam_t wrParam, void *paramValue);
#endif

#endif /* SVC_UNI_H_ */
