/**
* @file icss_ioctl.h
*
* @brief Contains structures and definitions that are used for remote input output control
*
* \par
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
* \par
*/
#ifndef _ICSS_IOCTL_H
#define _ICSS_IOCTL_H

#ifdef __cplusplus
extern "C" {
#endif

/* ========================================================================== */
/*                           Macros & Typedefs                                */
/* ========================================================================== */
/* IOCTL are classified by their type which is further qualified by opcodes within that type  */

/* IOCTL command code type */
/**
* @def ICSS_IOCTL_SWITCH_CMD
*      Ioctl Switch Command
*/
#define ICSS_IOCTL_SWITCH_CMD   1u
/**
* @def ICSS_IOCTL_STAT_CMD
*      Ioctl Statistics Command
*/
#define ICSS_IOCTL_STAT_CMD 	  2u

/* IOCTL Opcodes for type Switch Command */
/**
* @def ICSS_IOCTL_BASE
*      Ioctl Switch command base
*/
#define ICSS_IOCTL_BASE                                         0u
/**
* @def ICSS_IOCTL_RATELIMIT
*      Ioctl Ratelimit Command
*/
#define ICSS_IOCTL_RATELIMIT                      (ICSS_IOCTL_BASE + 1u)
/**
* @def ICSS_IOCTL_GET_PORT_CONFIG
*      Ioctl Get Port Config Command
*/
#define ICSS_IOCTL_GET_PORT_CONFIG                (ICSS_IOCTL_BASE + 2u)
/**
* @def ICSS_IOCTL_SET_PORT_CONFIG
*      Ioctl Set Port Config Command
*/
#define ICSS_IOCTL_SET_PORT_CONFIG                (ICSS_IOCTL_BASE + 3u)



/* Opcode definition for switch command */
/**
* @def ICSS_IOCTL_STAT_BASE
*      Ioctl Statistics command base
*/
#define ICSS_IOCTL_STAT_BASE 		0u
/**
* @def ICSS_IOCTL_STAT_CLEAR
*      Ioctl Clear Statistics command
*/
#define ICSS_IOCTL_STAT_CLEAR  	(ICSS_IOCTL_STAT_BASE +1u)
/**
* @def ICSS_IOCTL_STAT_GET
*      Ioctl Get Statistics command
*/
#define ICSS_IOCTL_STAT_GET		(ICSS_IOCTL_STAT_BASE +2u)


/** make the s/w  stats counters 64-bit wide */
typedef unsigned long long STATCTR;


/**
 * @brief  ICSS Statistics
 *  	   Statistics counters: Reflect cumulative statistics of enabled ports .
 */
typedef struct
{
	volatile STATCTR txUcast;			/**Number of Tx unicast packets*/
	volatile STATCTR txBcast;			/**Number of Tx unicast packets*/
	volatile STATCTR txMcast;			/**Number of Tx unicast packets*/
	volatile STATCTR txGoodFrames;		/**Number of Tx unicast packets*/
	volatile STATCTR txNetOctets;		/**Number of Tx unicast packets*/
	volatile STATCTR rxUcast;			/**Number of unicast packets rcvd*/
	volatile STATCTR rxBcast;			/**Number of broadcast packets rcvd*/
	volatile STATCTR rxMcast;			/**Number of multicast packets rcvd*/
	volatile STATCTR rxGoodFrames;		/**Total number of good frames rcvd*/
	volatile STATCTR rxNetOctets;		/**Total number of bytes rcvd*/
	volatile STATCTR rxUnknownProtocol;	/**Number of unknown protocol packets rcvd*/
	volatile STATCTR droppedPackets;	/**Number of dropped Broadcast packets*/
	volatile STATCTR rxErrorFrames;		/**Number of RX Error Frames*/
	volatile STATCTR txDiscards;		/**Tx Queue under flow count*/
	volatile STATCTR txErrors;			/**Number of TX Errors*/
	volatile STATCTR lateColl;			/**Current Tx queue level*/
	volatile STATCTR excessColl;		/**Number of excess collisions(Half Duplex)*/
	volatile STATCTR singleColl;		/**Number of single collisions (Half Duplex)*/
	volatile STATCTR multiColl;			/**Number of cut through unicast bytes*/
	volatile STATCTR defTx;				/**Number of transmissions deferred*/
	volatile STATCTR CSError;			/**Number of carrier sense errors*/
	volatile STATCTR macTxError;		/**Number of MAC transmit errors*/
	volatile STATCTR macRxError;		/**Number of MAC receive errors*/
	volatile STATCTR sqeTestError;		/**Number of MAC receive errors*/
} IcssSwitchStatistics;

/**
 * @brief Port VLAN command
 */
typedef struct _ALE_VLANCMD_T
 {
	Uint32  port;			/**Port*/
	Uint32  vid;			/**VLAN identifier*/
	Uint32  prio_port;		/**port priority 0 -7*/
	Uint32  CFI_port;		/**port CFI  0 /1 */
	Uint8   mem_port;		/**port number 0 - 2 */
	Uint8   unreg_port;		/**unregistered multicast Egress Ports */
	Uint8   regag_port;		/**register multicast Egress ports*/
	Uint8   untag_port;		/** Untag ports */
	Uint8   add[6];			/** Macid to Add */
	Uint32  flag;			/** Flag */
	Uint32  blocked;		/** Port to be blocked or not */
	Uint32  secure;			/** Secure */
	Uint32  ageable;		/** Ageable or not*/
	Uint32  aleTimeout;		/**timeout Expressed in millisecs */
	Uint8   aledump;		/**if 1 print ale table for debug purpose*/
 }ALE_VLANCMD;

/**
*  @brief Port command
*/
typedef struct _PORT_CMD_T
{
	Uint32  threshold;	/**Threshold*/
	Uint8   port;		/**Port number*/
	Uint32  value;		/**Value */
	Uint32  bl;			/**broadcast limit */
	Uint32  ml;			/**multicast limit */
	Uint8   EnDis;		/**1 -enable/0- Disable */
	Uint8   add[6];		/**Mac address */
    Uint32  phyMode;	/**Autoneg status	 */
}PORT_CMD;

/**
* @brief Packet priority structure
*/
typedef struct _PRIO_CMD_T
{
	Uint8 port;				/**Port number*/
	Uint8 prio_rx;			/** Receiving packet priority */
	Uint8 prio_tx;			/** Transmitting packet priority */
	Uint8 prio_switch;		/** switch priority */
	Uint8 hostRxCh;			/** packet with switch priority receive on this channel */
	Uint8 hostRxChSuper;	/** supervisory packet receive on this channel */
}PRIO_CMD;


/**
* @brief Switch control The following structure is used as param for all IOCTL of type switch command
*/
typedef struct SWITCHCONSCMD
{
    Uint32 	opcode;								/**opcode for switch control operation */
    int		(*consolePrint)(const char*,...); 	/**Function pointer to a print function */
    Uint8       usePrintFn;						/**flag that indicates that the provided Printfn must be used
      	  	  	  	  	  	  	  	  	  	  	  Must be set to 1, if consolePrint is to be used for logging */
    /**
    * @brief CmdType The structure determine the Command type
    */
    union
    {
        ALE_VLANCMD		 	AleVlanCmd;	/**Vlan command*/
        PORT_CMD			PortCmd;	/**Port command*/
        PRIO_CMD			PrioCmd;	/**Priority command*/
    }CmdType;
    Uint32 ret_type;	/**Return  Success/Failure */
}SwitchConsCmd;

/**
* @brief The following structure is used as param for all IOCTL related to STATS
*/
typedef struct STATSCMD
{
	Uint32 opcode ;						/**opcode for stats operations*/
	Uint8 portNum ;						/**stats portnum*/
	IcssSwitchStatistics  statsObj;		/**used with get stats command*/
}StatsCmd;


#ifdef __cplusplus
}
#endif

#endif /*_ICSS_IOCTL_H */
