/**
 * cpsw_ioctl.h
 * 
 *
 * Copyright (c) 2012 Texas Instruments Incorporated ALL RIGHTS RESERVED
 *
*/
/** \file   cpsw_ioctl.h
    \brief  CPSW3G Ioctl header file

    This file provides data structures that are required by the Ioctls. The 
    application or the driver can include this file to use the Ioctl's
 */

#ifndef _CPSW3G_IOCTL_H
#define _CPSW3G_IOCTL_H

#ifdef __cplusplus
extern "C" {
#endif

/* IOCTL are classified by their type which is further qualified by opcodes within that type  */

/* IOCTL command code type */
#define CPSW3G_IOCTL_SWITCH_CMD   1u
#define CPSW3G_IOCTL_STAT_CMD 	  2u

/* IOCTL Opcodes for typr Switch Command */
#define CPSW3G_IOCTL_BASE                                         0u
#define CPSW3G_IOCTL_PORT_STATISTICS_ENABLE         (CPSW3G_IOCTL_BASE + 1u)
#define CPSW3G_IOCTL_SET_PORT_CONFIG                (CPSW3G_IOCTL_BASE + 2u)
#define CPSW3G_IOCTL_GET_PORT_CONFIG                (CPSW3G_IOCTL_BASE + 3u)




/* Opcode definition for switch command */
#define CPSW3G_IOCTL_STAT_BASE 		0u	
#define CPSW3G_IOCTL_STAT_CLEAR  	(CPSW3G_IOCTL_STAT_BASE +1u)
#define CPSW3G_IOCTL_STAT_GET		(CPSW3G_IOCTL_STAT_BASE +2u)


/**
 * \brief MII Read/Write PHY register
 *
 * Parameters to read/write a PHY register via MII interface
 */
typedef struct
{
    Uint32      phyNum;             /**< Phy number to be read/written */
    Uint32      regAddr;            /**< Register to be read/written */
    Uint32      data;               /**< Data to be read/written */
} Cpsw3gPhyParams;

/**
 * \brief MAC  Address params
 *
 * Parameters for Configuring Mac address
 */
typedef struct
{
    Uint32      channel;            /**< Channel number for addr params */
    String      macAddress;         /**< Mac address  */
} CpmacAddressParams;


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


/**
 * \brief CPSW3G Statistics
 *
 *  Statistics counters: Reflect cumulative statistics of enabled ports . The names
 *  of the counters in  this structure are of "MIB style" and correspond directly
 *  to the hardware counters provided by CPSW3G.
 */
typedef struct
{
  volatile STATCTR   ifInGoodFrames;
  volatile STATCTR   ifInBroadcasts;
  volatile STATCTR   ifInMulticasts;
  volatile STATCTR   ifInPauseFrames;
  volatile STATCTR   ifInCRCErrors;
  volatile STATCTR   ifInAlignCodeErrors;
  volatile STATCTR   ifInOversizedFrames;
  volatile STATCTR   ifInJabberFrames;
  volatile STATCTR   ifInUndersizedFrames;
  volatile STATCTR   ifInFragments;
  volatile STATCTR   reserved;
  volatile STATCTR   reserved2;
  volatile STATCTR   ifInOctets;
  volatile STATCTR   ifOutGoodFrames;
  volatile STATCTR   ifOutBroadcasts;
  volatile STATCTR   ifOutMulticasts;
  volatile STATCTR   ifOutPauseFrames;
  volatile STATCTR   ifDeferredTransmissions;
  volatile STATCTR   ifCollisionFrames;
  volatile STATCTR   ifSingleCollisionFrames;
  volatile STATCTR   ifMultipleCollisionFrames;
  volatile STATCTR   ifExcessiveCollisionFrames;
  volatile STATCTR   ifLateCollisions;
  volatile STATCTR   ifOutUnderrun;
  volatile STATCTR   ifCarrierSenseErrors;
  volatile STATCTR   ifOutOctets;
  volatile STATCTR   if64OctetFrames;
  volatile STATCTR   if65To127OctetFrames;
  volatile STATCTR   if128To255OctetFrames;
  volatile STATCTR   if256To511OctetFrames;
  volatile STATCTR   if512To1023OctetFrames;
  volatile STATCTR   if1024ToUPOctetFrames;
  volatile STATCTR   ifNetOctets;
  volatile STATCTR   ifRxSofOverruns;
  volatile STATCTR   ifRxMofOverruns;
  volatile STATCTR   ifRxDMAOverruns;
} Cpsw3gStatistics;



typedef struct _PORT_CMD_T
{
        Uint32  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 */
        Uint8   linkStat;
}PORT_CMD;



/** The following structure is used as param for all IOCTL of type switch command */
typedef struct SWITCHCONSCMD
{
    Uint32 	opcode;           /*  opcode for switch control operation */
    /* Function pointer to a print function */
    int		(*consolePrint)(const char*,...); 
    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 */
    PORT_CMD			PortCmd;

    Uint32 ret_type;   /* Return  Success/Failure */

}SwitchConsCmd;



/** The following structure is used as param for all IOCTL related to STATS */
typedef struct CPSWSTATSCMD
{
	Uint32 opcode ;  /* opcode for stats operations */
	Cpsw3gStatistics  statsObj; /* used with get stats command */
}CpswStatsCmd;

#ifdef __cplusplus
}
#endif

#endif /*_CPSW3G_IOCTL_H */
